日期:2014-05-16  浏览次数:20692 次

formValidator插件 ajaxValidator中文传值被忽略
IDE是Eclipse
框架为SpringMVC 下的  Maven项目
在验证输入的名称是否存在时  用了formValidator组件的ajaxValidator方法
传递英文时 后台可以接收  传递中文时   提示含%符号等被忽略
2013-1-18 16:42:30 org.apache.tomcat.util.http.Parameters processParameters
信息: Character decoding failed. Parameter [name] with value [%u54C8] has been ignored. Note that the name and value quoted here may be corrupted due to the failed decoding. Use debug level logging to see the original, non-corrupted values.
 Note: further occurrences of Parameter errors will be logged at DEBUG level.

前台代码:
$("#name").formValidator({onFocus:"请输入项目的名称,必填"})
     .inputValidator({min:1,empty:{leftEmpty:false,rightEmpty:false,emptyError:"不能使用空格"},onError:"项目名称不能为空,请确认"})
     .ajaxValidator({
     dataType : "json",
     async : true,
     url : encodeURI(encodeURI("/xing-zhi/project/findProByName")),
     success : function(data) {
     if(data=="0") {
     return true;
     }
     return "该项目名称已存在,请更换项目名称";
     },
     error : function(jqXHR, textStatus, errorThrown) {
     alert("服务器没有返回数据,可能服务器忙,请重试"+errorThrown);
     },
     onError : "该项目名称已存在,请更换项目名称",
     onWait : "正在对用户名进行合法性校验,请稍候..."
     }).defaultPassed();

后台代码
@ResponseBody
@RequestMapping(value = "/findProByName", method=RequestMethod.GET)
public String findProByName(String name) {
System.out.println("name:" + name);
String result = "0";
Project project = projectService.findProByName(name);
if(project!=null) {
result = "1";
}
return result;
}
上网搜了一些  有的说在URI前面加encodeURI的  我加了也不好用   ajax的type改为POST也不好使   求解答  本人的分数全押宝了  只能贡献出20大洋  见谅
------解决方案--------------------
是编码发送的数据,不是url地址。。url地址不用编码。。

你的这个应该是配置问题吧,自己找找不忽略这种数据格式的配置,不行你就需要修改源代码,再次encodeURI要发送的数据了