前几天遇到过这个问题(Ref:http://www.cnblogs.com/xiandedanteng/p/4168609.html),问题在页面的组件name和和注解的@param名匹配不对,这个好解决,一一对好就行了。

但是,这回情况不一样了,我的页面控件是类似这样的:

<p style="height:280px;display:block;">
    <span class="req">
        <label><input type="checkbox" value="A" name="to" />&nbsp;A</label>
        <label><input type="checkbox" value="B" name="to" />&nbsp;B</label>
        <label><input type="checkbox" value="C" name="to" />&nbsp;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" />&nbsp;A</label>
        <label><input type="checkbox" value="B" name="to" />&nbsp;B</label>
        <label><input type="checkbox" value="C" name="to" />&nbsp;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 ()的更多相关文章

  1. SpringMVC报错The request sent by the client was syntactically incorrect ()

    springmvc数据绑定出的错 在数据绑定的时候一定要主意Controller方法中的参数名和jsp页面里的参数名字是否一致或者按照绑定的规范来写, 如果不一致,可能回报如下错误: The requ ...

  2. "The request sent by the client was syntactically incorrect ()"问题定位及解决:

    Spring MVC "The request sent by the client was syntactically incorrect ()"解决办法: 把spring日志级 ...

  3. The request sent by the client was syntactically incorrect问题解决

    The request sent by the client was syntactically incorrect意思嘛,google翻译一下 通过日志不难看出,是由参数不匹配造成的. 所以对于Da ...

  4. 错误:The request sent by the client was syntactically incorrect的解决

    问题: 错误400-The request sent by the client was syntactically incorrect. springMVC中,某个页面提交时报400错误,如下图. ...

  5. spring mvc 在上传图片时,浏览器报The request sent by the client was syntactically incorrect

    项目中,在一个jsp页面里其它图片上传是功能是可以使用的,当我自己新加了一个图片上传时,提交表单后,浏览器报The request sent by the client was syntactical ...

  6. SpringMVC---400错误The request sent by the client was syntactically incorrect ()

    在SpringMVC中使用@RequestBody和@ModelAttribute注解时遇到了很多问题,现记录下来. @ModelAttribute这个注解主要是将客户端请求的参数绑定参数到一个对象上 ...

  7. HTTP Status 400 - description The request sent by the client was syntactically incorrect.

    HTTP Status 400 - type Status report message description The request sent by the client was syntacti ...

  8. The request sent by the client was syntactically incorrect.

    HTTP Status 400 - type Status report message description The request sent by the client was syntacti ...

  9. 错误The request sent by the client was syntactically incorrect ()的解决

    http://www.cnblogs.com/xiandedanteng/p/4168609.html 这个错误是SpringMVC报出来的,见到它意味着html/jsp页面的控件名称 和 contr ...

随机推荐

  1. ftp无法连接的原因

    1.需求 记录碰到的ftp无法连接的原因 2.解决方案 .确认ftp服务开启. .确认21端口没有被占用. .确认有目录的执行权限. .确认配置文件中的目录读写权限正确. .关闭SELinux 修改/ ...

  2. 阿里云服务器ubuntu安装java运行环境

    服务器 阿里云服务器ubuntu安装java运行环境 转:http://www.codingyun.com/article/45.html 今天来给大家介绍一下在阿里云ubuntu服务器下安装java ...

  3. 2018超详细sublime text3+python3.x安装配置教程(附常用插件安装教程)

    导读 本文是关于2018年7月最新版sublime text3+pythin3.x下载及安装配置教程,sublime text3版本为3176,python版本为3.7,安装环境是基于windows1 ...

  4. apache 配置 SSL

    假设apache已经装好 1.使用yum install openssl,安装openssl 2.开启httpd.conf中LoadModule ssl_module modules/mod_ssl. ...

  5. [9018_1963][IOI_1998]Picture

    题目描述 N(N<5000) 张矩形的海报,照片和其他同样形状的图片贴在墙上.它们的边都是垂直的或水平的.每个矩形可以部分或者全部覆盖其他矩形.所有的矩形组成的集合的轮廓称为周长.写一个程序计算 ...

  6. urb数据结构【转】

    转自:http://blog.csdn.net/myarrow/article/details/7025065 版权声明:本文为博主原创文章,未经博主允许不得转载. 目录(?)[-] 一 transf ...

  7. VS2015开发的C++应用如何不依赖Visual C++ 2015 redistributable?

    1,“项目属性,C/C++,代码生成”,“运行库改”为“多线程(/MT)”.* MT开头的是静态引用,MD开头的是动态引用,d结尾的是Debug调试版本,没有d的是Release发布版本,所以就一 共 ...

  8. docker入门之:centos6.5 安装docker

    centos6.5 : 使用EPEL库安装docker: # sudo yum install -y  http://mirrors.yun-idc.com/epel/6/i386/epel-rele ...

  9. Hmailserver搭建邮件服务器

    Hmailserver安装很简单不需要多说,自己去百度 Hmailserver配置: 输入安装时设置的密码登录Hmailserver 添加域名,如:域名是:mail.abc.com这里添加的时候应该填 ...

  10. 利用Excel导出sql语句

    在工作中遇到了需要用数据库的insert语句,本来是极其简单的事情,但是碰到了有n个(n很大)字段的表,写insert语句就是极其痛苦的事情了,即使只是复制粘贴也是很费力不讨好的一件事.正好手头有ex ...