又见The request sent by the client was syntactically incorrect ()
2014-12-28 01:04
323 查看
前几天遇到过这个问题(Ref:http://www.cnblogs.com/xiandedanteng/p/4168609.html),问题在页面的组件name和和注解的@param名匹配不对,这个好解决,一一对好就行了。
但是,这回情况不一样了,我的页面控件是类似这样的:
而控制器是这样写的:
看,to部分对应一点没错,但是,问题来了,如果name为to的一组复选框一个都没有选中的话,那么,提交页面后就会报The request sent by the client was syntactically incorrect ()错误。
但是,如果哪怕只要选中一个,程序就正常运行了。
我是通过添加一个默认的隐藏的选中复选框来避免这个错误的,代码如下:
这样,这组复选框就不必非要选中一个了,当然,后台需要添加点过滤措施。
应该是SpringMVC自身的问题,希望它能修正这个Bug。
但是,这回情况不一样了,我的页面控件是类似这样的:
<p style="height:280px;display:block;"> <span class="req"> <label><input type="checkbox" value="A" name="to" /> A</label> <label><input type="checkbox" value="B" name="to" /> B</label> <label><input type="checkbox" value="C" name="to" /> C</label> </span> <label><span></span></label> </p>
而控制器是这样写的:
@RequestMapping(value="/sendEmailReport") public String sendEmailReport(@RequestParam("idTxt") String id, @RequestParam("to") String[] to, @RequestParam("cc") String[] cc, @RequestParam("bcc") String[] bcc, HttpServletRequest request, HttpServletResponse response){ 。。。 }
看,to部分对应一点没错,但是,问题来了,如果name为to的一组复选框一个都没有选中的话,那么,提交页面后就会报The request sent by the client was syntactically incorrect ()错误。
但是,如果哪怕只要选中一个,程序就正常运行了。
我是通过添加一个默认的隐藏的选中复选框来避免这个错误的,代码如下:
<p style="height:280px;display:block;"> <span class="req"> <label><input type="checkbox" value="A" name="to" /> A</label> <label><input type="checkbox" value="B" name="to" /> B</label> <label><input type="checkbox" value="C" name="to" /> C</label> <label><input type="checkbox" value="" checked name="to" style="display:none;"/></label> </span> <label><span></span></label> </p>
这样,这组复选框就不必非要选中一个了,当然,后台需要添加点过滤措施。
应该是SpringMVC自身的问题,希望它能修正这个Bug。
相关文章推荐
- The request sent by the client was syntactically incorrect.
- Spring MVC "The request sent by the client was syntactically incorrect "解决办法
- springMVC 页面填写日期运行时发生异常!The request sent by the client was syntactically incorrect
- SpringMVC---400错误The request sent by the client was syntactically incorrect ()
- 错误:The request sent by the client was syntactically incorrect的解决
- 解决 spring mvc3.1下post json出现HTTP Status 400 The request sent by the client was syntactically incorrect
- springMVC 接受对象 The request sent by the client was syntactically incorrect.
- Spring MVC "The request sent by the client was syntactically incorrect ()"解决办法
- The request sent by the client was syntactically incorrect-SpringMVC问题详解
- The request sent by the client was syntactically incorrect
- 错误400-The request sent by the client was syntactically incorrect
- The request sent by the client was syntactically incorrect解决
- http 400 Bad Request The request sent by the client was syntactically incorrect
- The request sent by the client was syntactically incorrect ().(404)
- springMVC日期转换及The request sent by the client was syntactically incorrect.解决办法
- 用 @ModelAttribute 出现The request sent by the client was syntactically incorrect.的解决办法
- 搭建ssm框架遇到的问题:The request sent by the client was syntactically incorrect
- springmvc 上传文件的时候.The request sent by the client was syntactically incorrect
- HTTP 400: Bad Request The request sent by the client was syntactically incorrect
- The request sent by the client was syntactically incorrect (). 的某个解决办法