The request sent by the client was syntactically incorrect.(转载)

这个错误是SpringMVC报出来的,见到它意味着html/jsp页面的控件名称 和 controller里函数的参数不符。

好比界面有个这样的form

    <form name="form1" action="uploadDocument.html" method="post" ENCTYPE="multipart/form-data">
    <div class="form" >
            <p>
                <span class="req"><input id="remarkTxt"  name="remarkTxt" class="field size4" title="Enter the date" /></span>
                <label>Remark: <span>(The brief introduction of the file)</span></label>
            </p>

            <p>
                <span class="req"><input type="file"  name="uploadFileCtrl" class="field size4" title="Choose the file" /></span>
                <label>Upload file: <span>(Click browse to choose)</span></label>
            </p>
    </div>

    <div class="buttons">
        <input id="queryBtn" type="button" class="button" value="Submit" />
    </div>

    </form>

而对应的函数参数应该这样写:

@RequestMapping(value="/uploadDocument")
    public String uploadDocument( @RequestParam("remarkTxt") String remark,
                                  @RequestParam("uploadFileCtrl") MultipartFile file,                                  HttpServletRequest request,                                  HttpServletResponse response){    ....    }}

注意上述粗体字的一一对应关系。

分类: Spring,Java Web应用开发

时间: 2024-08-27 22:28:01

The request sent by the client was syntactically incorrect.(转载)的相关文章

400 Bad Request The request sent by the client was syntactically incorrect ().

项目中一直出现400错误,后面搜索下,发现如下内容. SpringMVC报错信息为The request sent by the client was syntactically incorrect () 在数据绑定的时候一定要主意Controller方法中的参数名和jsp页面里的参数名字是否一致或者按照绑定的规范来写,如果不一致,可能回报如下错误: The request sent by the client was syntactically incorrect (). 从字面上理解是:客户

又见The request sent by the client was syntactically incorrect ()

前几天遇到过这个问题(Ref:http://www.cnblogs.com/xiandedanteng/p/4168609.html),问题在页面的组件name和和注解的@param名匹配不对,这个好解决,一一对好就行了. 但是,这回情况不一样了,我的页面控件是类似这样的: <p style="height:280px;display:block;"> <span class="req"> <label><input typ

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

在SpringMVC中使用@RequestBody和@ModelAttribute注解时遇到了很多问题,现记录下来. @ModelAttribute这个注解主要是将客户端请求的参数绑定参数到一个对象上,不用将很多参数@RequestParam或是@PathVariable. 但是在使用过程中遇到了问题, 第一次Html端请求代码如下,请求方式1 // 简单键值对 var data = { productTypeIds : vproducttypeid, channelTypeId : vchan

解决SpringMVC入参出现The request sent by the client was syntactically incorrect请求语法错误方法

使用SpringMVC出现The request sent by the client was syntactically incorrect.请求错误如下: 可以确定为提交的表单数据和目标方法的入参不一致所导致,表单数据可以多于目标入参个数,但目标参数没有被赋值,则会出现该异常,如下情况: 表单数据: 目标方法: Employee字段: 比对表单数据和Employee字段,可以发现,表单数据比Employee字段少,再加上目标方法的入参是一个 Employee对象,所以将会出现提交的数据不足,

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

springMVC数据绑定,对我们而言,能够更轻松的获取页面的数据,但是必须要注意的一点就是: Controller方法中的参数名和jsp页面里的参数名字是否一致或者按照绑定的规范来写 在Controller中@RequestParam("m_level") Integer m_level 那么在jsp页面上的数据 <select name="m_level"> <option value="一级">一级</opti

The request sent by the client was syntactically incorrect. 400 问题

The request sent by the client was syntactically incorrect. 这个问题是因为 SpringMvc controller 里面的方法参数和请求参数不匹配. 请求参数在 Contoller 的方法参数对象中不存在则会报这个错误. 如 : Controller 里面的方法 @RequestMapping(value = "/login/signin", method = RequestMethod.POST) public @Resp

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

问题:错误400-The request sent by the client was syntactically incorrect. springMVC中,某个页面提交时报400错误,如下图. 解决方法: 1.在网上找了一下,答案是通常遇到这个错误是因为前端jsp页面的控件名称和controller中接收的参数名称不一致.但仔细对比了一遍发现没有问题.很郁闷. 2.然后就反复的提交那个页面进行测试,发现了问题,因为我是将多个参数作为一个实体传至controller,发现某个文本框为空时,提交

错误400-The request sent by the client was syntactically incorrect

出错部分是学习SpringMVC 时学习https://my.oschina.net/gaussik/blog/640164,在添加博客文章部分出现了这个问题. The request sent by the client was syntactically incorrect 说的意思是:由客户端发送的请求是语法上是不正确的. 上网找了很多资料,大部分都是说前端jsp页面的控件名称(name)和controller中接收的参数名称不一致,检查以后确实存在这个问题,修改以后还是没有解决,这说明别

POST 400 Bad Request The request sent by the client was syntactically incorrect

最近在做Web开发的时候,使用$.post提交数据,但是回调函数却没有被触发,按F12看控制台输出是:POST *** 400 Bad Request 后台是SpringMVC的,设置了断点也不会被触发. 后来查看JQuery资料了解到,$.post提交数据只有成功时才触发回调函数,于是改用$.ajax提交数据,添加error回调函数,得到错误信息了,如下图: 这个问题是什么原因造成的呢? 后来经过测试发现,是表单提交的内容数据类型与实体的(也就是数据表字段)的数据类型不匹配导致的. 在提交表单