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;
}
跳转成功。
- HTTP Status 400 - Required String parameter 'userName' is not present 错误
- 400错误,Required String parameter 'paramter' is not present
- spring mvc 400 Required String parameter 'quizId' is not present 前端参数找不到
- HTTP Status 400 - Required String parameter '/q' is not present
- HTTP Status 400 - Required CommonsMultipartFile parameter 'files' is not present
- HTTP Status 400 - Required MultipartFile parameter 'file' is not present
- HTTP Status 400 - Required long parameter 'id' is not present
- HTTP Status 400 - Required Long parameter 'id' is not present
- ABP PUT、DELETE请求错误405.0 - Method Not Allowed 因为使用了无效方法(HTTP 谓词) 引发客户端错误 No 'Access-Control-Allow-Origin' header is present on the requested resource
- 关于使用spring mvc时出现 HTTP Status 400 - Required String parameter 'xx' is not present
- 【知了堂学习笔记】_springMVC_文件上传_错误_Required CommonsMultipartFile parameter 'file' is not present
- 【ASP.NET Core】解决“The required antiforgery cookie "xxx" is not present”的错误
- springmvc @RequestParam 获取参数 HTTP Status 400 - Required String parameter 'xx' is not present
- HTTP Status 400 - Required CommonsMultipartFile[] parameter 'XXX' is not present
- MultipartFile文件上传,400 - Required MultipartFile parameter 'file' is not present
- Python 出现错误 SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform.
- WPF 错误:DependencyProperty.UnsetValue}' is not a valid value for property 'Background'
- ios常见错误之 Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' - perhaps the designated entry point is not set?
- Target runtime Apache Tomcat v6.0 is not defined错误解决办法