前几天遇到过这个问题(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. CSU 2031

    2031: Barareh on Fire Submit Page   Summary   Time Limit: 3 Sec     Memory Limit: 512 Mb     Submitt ...

  2. testng自定义注解

    在testng中大部分的注解已经可以满足我们测试的需求,但是在测试的时候想要通过注解的方式加入自己测试一些内容,比如 测试项目 测试描述  验证点等信息,可通过自定义注解的方式实现. 具体操作步骤如下 ...

  3. 使用fdisk命令对linux硬盘进行操作

    fdisk是linux自带的硬盘分区工具,可以对硬盘进行分区,或者对硬盘分区进行调整.本次试验环境请参考[Linux磁盘系统基础知识] 首先选择要进行操作的磁盘 [root@a ~]# fdisk / ...

  4. python的资源整合

    一位大牛整理的Python资源 Python基本安装: * http://www.python.org/ 官方标准Python开发包和支持环境,同时也是Python的官方网站:* http://www ...

  5. linux下修改mysql数据库编码后无法启动解决办法

    linux下老版本的Mysql修改数据库编码的方法是 修改my.cnf vi /etc/my.cnf 在[client]下添加 default-character-set=utf8 在[mysqld] ...

  6. 流畅的python第九章笔记 python风格的python

    9.1对象表示形式 __repr__和__str__这两个方法都是用于显示的,__str__是面向用户的,而__repr__面向程序员. 我们打印下面的A是默认输出这个对象的类型,我们对B进行了修改_ ...

  7. java基础练习 12

    public class Twelfth { /*海滩上有一堆桃子,五只猴子来分.第一只猴子把这堆桃子凭据分为五份,多了一个,这只猴子把多的一个扔入海中,拿走了一份.第二只猴子把剩下的桃子又平均分成五 ...

  8. svn 基本使用

    通过脚本删除物理文件已经不存在的文件 svn st | sed -n '/!/p' | awk '{print $2}' | xargs svn delete 或 svn st | awk '{if ...

  9. CF978E Bus Video System【数学/前缀和/思维】

    [链接]: CF [分析]: 设上车前人数 x ,中途最大人数为 x+max ,最小人数为 x+min (max≥0,min≤0) 可得不等式组 x+max≤w, x+min≥0 整数解个数为 max ...

  10. 牛客小白月赛3 B 躲藏【动态规划/字符串出现cwbc子序列多少次】

    链接:https://www.nowcoder.com/acm/contest/87/B来源:牛客网 XHRlyb和她的小伙伴Cwbc在玩捉迷藏游戏 Cwbc藏在多个不区分大小写的字符串中. 好奇的X ...