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

来源:互联网 发布:做淘宝店铺用什么软件 编辑:程序博客网 时间:2024/05/10 19:21

springmvc数据绑定是一个很好的东西,在数据绑定的时候一定要主意Controller方法中的参数名和jsp页面里的参数名字是否一致或者按照绑定的规范来写,如果不一致,可能会报如下错误: 
The request sent by the client was syntactically incorrect ().从字面上理解是:客户端发送的请求语法错误。实际就是springmvc无法实现数据绑定。 
随便举个例子说明: 

 

  1. public String saveOrder(  
  2.             String[] itemIds,  
  3.             @RequestParam("level")String[] levels,  
  4.             ModelMap modelMap)  

 

这里面的itemIds就一定要和jsp页面里的参数名字相同;如果你非要命名不相同要像levels的写法那样通过@RequestParam来转换,其中括号里面的level是jsp页面里面的参数名字,levels是在controller方法中要用到的名字;如果jsp页面中没有itemIds和 level任何一个参数,也会报相同的错误,就是因为springmvc无法实现数据的绑定。

 

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

<form method="post" action="${ctx}/storaget/save" class="pageForm required-validate" onsubmit="return validateCallback(this, dialogAjaxDone)">

改变---->

<form method="post" action="${ctx}/storaget/save" enctype="multipart/form-data" class="pageForm required-validate" onsubmit="return iframeCallback(this, dialogAjaxDone);" > 

 

 

 

0 0
原创粉丝点击