400错误,Required String parameter 'paramter' is not present
1.就拿简单的登录来说吧,这是开始的代码
@RequestMapping(value="/login")
public ModelAndView login(@RequestParam(“loginname”) String loginname,
@RequestParam("password") String password,
HttpSession session,
ModelAndView mv){
// 调用业务逻辑组件判断用户是否可以登录
User user = hrmService.login(loginname, password);
if(user != null){
// 将用户保存到HttpSession当中
session.setAttribute(HrmConstants.USER_SESSION, user);
// 客户端跳转到main页面
mv.setViewName("redirect:/main");
}else{
// 设置登录失败提示信息
mv.addObject("message", "登录名或密码错误!请重新输入");
// 服务器内部跳转到登录页面
mv.setViewName("forward:/loginForm");
}
return mv;
}
在浏览器中输入localhost:8080/xxx/login,爆出了400,Required String parameter 'paramter' is not present。
2.controller类中,在注解@RequestParam,添加value="paramter",required=false.切记,是false.就OK了。
@RequestMapping(value="/login")
public ModelAndView login(@RequestParam(value="loginname",required=false) String loginname,
@RequestParam(value="password",required=false) String password,
HttpSession session,
ModelAndView mv){
// 调用业务逻辑组件判断用户是否可以登录
User user = hrmService.login(loginname, password);
if(user != null){
// 将用户保存到HttpSession当中
session.setAttribute(HrmConstants.USER_SESSION, user);
// 客户端跳转到main页面
mv.setViewName("redirect:/main");
}else{
// 设置登录失败提示信息
mv.addObject("message", "登录名或密码错误!请重新输入");
// 服务器内部跳转到登录页面
mv.setViewName("forward:/loginForm");
}
return mv;
}
跳转成功。
400错误,Required String parameter 'paramter' is not present的更多相关文章
- HTTP Status 400 - Required String parameter 'userName' is not present 错误
HTTP Status 400 - Required String parameter 'userName' is not present 错误 先mark 有时间详细写 参考链接: https:/ ...
- Jpa 报错 :HTTP Status 400 - Required String parameter 'xx' is not present
一.问题描述 使用Springboot JPA 做分页查询,报错Required String parameter 'xx' is not present,后端未接受到请求 二.解决方案: 使用的请求 ...
- required string parameter 'XXX'is not present 的几种情况
required string parameter 'XXX'is not present 的几种情况 情况一:原因是由于头文件类型不对,可以在MediaType中选择合适的类型,例如GET和POST ...
- required string parameter XXX is not present
@RequestParam jQuery调用方式: deleteFile: function(filePath) { return ajax({ method: 'POST', url: '/cm/s ...
- org.springframework.web.bind.MissingServletRequestParameterException: Required String parameter 'xxxx' is not present
org.springframework.web.bind.MissingServletRequestParameterException: Required String parameter 'xxx ...
- 后台接收参数报错 Required String parameter 'id' is not present
来自:https://blog.csdn.net/qq_15238647/article/details/81539287 关于ajax请求spring后台出现 Required String par ...
- 报错:required string parameter XXX is not present
报错:required string parameter XXX is not present 不同工具发起的get/delete请求,大多数不支持@RequestParam,只支持@PathVari ...
- Springboot 错误信息:Required String parameter 'loginname' is not present 引发的研究
@PostMapping("/reg/change")public CommonSdo change( @RequestParam(value = "oldPasswor ...
- Required String parameter 'images' is not present
后台控制层控制为非必填即可: @RequestMapping("/addDo") @SJson @SLog(description = "Car_main") ...
随机推荐
- URL 长度有限制吗?
众所周知,传递小量参数(在没有其他原因,例如隐藏参数值的情况下)推荐使用GET方法,传递大量参数推荐使用POST方法.原因是什么呢? 原因是传说GET方法是通过URL来传递,而URL的长度是受限的,而 ...
- Bitmap具体解释与Bitmap的内存优化
感觉这里的排版看着更舒服些 Bitmap具体解释与Bitmap的内存优化 一.Bitmap: Bitmap是Android系统中的图像处理的最重要类之中的一个.用它能够获取图像文件信息,进行图像剪切. ...
- Java并发和多线程:序
近期,和不少公司的"大牛"聊了聊,当中非常多是关于"并发和多线程"."系统架构"."分布式"等方面内容的.不少问题, ...
- 谈谈CListCtrl如何调整行高
原文链接: http://blog.csdn.net/sstower/article/details/9094939 调整CListCtrl 行高通常有3种方法: 1.设定字体2.设定图片3.处理Me ...
- sumatrapdf 软件介绍
sumatrapdf 软件介绍 介绍 支持PDF, ePub, Mobi, XPS, DjVu, CHM, CBZ 和 CBR格式的电子文件 仅支持Windows,原因见官网论坛 绿色版,小巧,于此 ...
- MATLAB(1)——基本调试方法(Debug)
作者:桂. 时间:2017-02-28 07:06:30 链接:http://www.cnblogs.com/xingshansi/articles/6477185.html 声明:转载请注明出处, ...
- Spring Cloud 通过代码自定义配置Ribbon
我们还是先从官网文档开始学习,如下图所示,我们可以搞一个测试配置类,来验证是否真的可以通过代码来自定义配置Ribbon,但文档明确给出了警告:即这个测试配置类不能放在@ComponentScan所扫描 ...
- 告诉你38个MySQL数据库的小技巧
无论是运维.开发.测试,还是架构师,数据库技术是一个必备加薪神器,那么,一直说学习数据库.学MySQL,到底是要学习它的哪些东西呢? 1.如何快速掌握MySQL? 培养兴趣 兴趣是最好的老师,不论学习 ...
- cocos2d-x解决中文乱码问题的几种办法
昨天改写cocos2d-x的例程,想在其基础上加上一个计分系统.没有分数实在让人没有玩下去的动力! 我在主场景上加上了一个CCLabelTTF,用于显示分数. 但是意外的发现,当内容含有中文时,CCL ...
- 每日英语:Why 'The Voice' Is China's No. 1 TV Show
U.S. fans of the hit talent show 'The Voice' may take for granted that its judges sit with their bac ...