[英]SpringMVC4 Error Bad Request when on a Post with a select field
I am getting an 400 Error - Bad Request 我收到400错误-错误的请求
Type Status Report 类型状态报告
Description The server cannot or will not process the request due to something that is perceived to be a client error (eg, malformed request syntax, invalid request message framing, or deceptive request routing). 描述由于某些东西被认为是客户端错误(例如,格式不正确的请求语法,无效的请求消息框架或欺骗性的请求路由),服务器无法或不会处理请求。
The problem part on the form is comming from: 表单上的问题部分来自:
<form:select path="farm" required="required">
<form:option value="NONE">--SELECT--</form:option>
<form:options items="${farms}" itemValue="key" itemLabel="name"/>
</form:select>
this is the controller 这是控制器
@RequestMapping(value = "/saveUser", method = RequestMethod.POST)
public ModelAndView saveUser(@ModelAttribute User user) {
if(user.getKey() == null) {
user.setDateCreated(new Date());
userService.addUser(user);
}
else userService.updateUser(user);
return new ModelAndView("redirect:/users");
}
If I remove the select everything works correctly. 如果我删除选择,一切正常。 Any help would be greatly appreciated.
任何帮助将不胜感激。
Please check the value parameter inside select tag. 请检查select标记内的value参数。 Most of the times it creates a problem with the values containing hyphen or spaces etc. Eg value = "value - one" Browser doesn't recognize this.
大多数情况下,它会产生包含连字符或空格等值的问题。例如,value =“ value-one”浏览器无法识别此问题。 It should be like this value = "valueone" .
应该像这个值=“ valueone”。 Inspect the page element on browser and verify the select tag option values.
检查浏览器上的页面元素,并验证选择标记选项值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.