前几天遇到过这个问题(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. Agile已死, Agility长存

    注:本文系作者独立翻译,可以随意转载.如有雷同,纯属巧合.原文地址:http://pragdave.me/blog/2014/03/04/time-to-kill-agile/ P.s. 第一次自己翻 ...

  2. [ CodeVS冲杯之路 ] P1116

    不充钱,你怎么AC? 题目:http://codevs.cn/problem/1116/ 数据很小,DFS可A,每层枚举颜色,判断相邻的点是否有重复的颜色,记得回溯时把颜色染回0,即无颜色 这里我使用 ...

  3. 杭电oj2031、2033、2070、2071、2075、2089、2090、2092、2096-2099

    2031  进制转换 #include<stdio.h> #include<string.h> int main(){ int n,i,r,x,j,flag; ]; while ...

  4. 【原创】Linux环境下的图形系统和AMD R600显卡编程(9)——R600显卡的3D引擎和图形流水线

    1. R600 3D引擎 R600核心是AMD一款非常重要的GPU核心,这个核心引入了统一处理器架构,其寄存器和指令集同以前的GPU 都完全不同,对其编程也有比较大的区别. 图1显示了R600 GPU ...

  5. Centos7下zabbix部署(五)定义报警媒介-微信

    1.注册微信 注册过程参考地址:https://www.cnblogs.com/hanyifeng/p/5368102.html 主要需要以下一些信息 CorpID :     wwxxxxxxxxx ...

  6. poj 1981(单位圆覆盖最多点问题模板)

    Circle and Points Time Limit: 5000MS   Memory Limit: 30000K Total Submissions: 7327   Accepted: 2651 ...

  7. J.U.C并发框架源码阅读(十六)FutureTask

    基于版本jdk1.7.0_80 java.util.concurrent.FutureTask 代码如下 /* * ORACLE PROPRIETARY/CONFIDENTIAL. Use is su ...

  8. (11)C#值类型和引用类型,堆和栈,ref和out,装箱和拆箱

    一.值类型和引用类型定义 以内存中的存在方式可以把变量分成两大类型,值类型和引用类型. 值类型:系统只占用一块内存,数据直接存储在内存里. 引用类型:系统占用两块内存,一块存放地址,另一块存放实际数据 ...

  9. 「kuangbin带你飞」专题二十 斜率DP

    layout: post title: 「kuangbin带你飞」专题二十 斜率DP author: "luowentaoaa" catalog: true tags: mathj ...

  10. Linq GroupJoin , Join

    static void Main(string[] args) { List<Person> persons = new List<Person> { }, }, }; Lis ...