2013-02-21 129 views
1

如果我输入密码时应作为Admin$&%^Admin$&^%然后我Ajax调用的作品,但如果我输入像这样 Admin$!%Admin$!%^。 Ajax调用抛出以下异常.....%为什么不允许

在探索我发现,请帮忙作为即时通讯无法取得的根本原因这个问题

INFO: Character decoding failed. Parameter [txt_password] with value [Admin$!%] has been ignored. No 
te 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. 
java.io.CharConversionException: EOF 
     at org.apache.tomcat.util.buf.UDecoder.convert(UDecoder.java:80) 
     at org.apache.tomcat.util.buf.UDecoder.convert(UDecoder.java:46) 
     at org.apache.tomcat.util.http.Parameters.urlDecode(Parameters.java:410) 
     at org.apache.tomcat.util.http.Parameters.processParameters(Parameters.java:370) 
     at org.apache.tomcat.util.http.Parameters.processParameters(Parameters.java:217) 
     at org.apache.catalina.connector.Request.parseParameters(Request.java:2647) 
     at org.apache.catalina.connector.Request.getParameter(Request.java:1106) 
     at org.apache.catalina.connector.RequestFacade.getParameter(RequestFacade.java:355) 
     at javax.servlet.ServletRequestWrapper.getParameter(ServletRequestWrapper.java:158) 

Special characters are not allowed inside the query string. They must be replaced by a "%" followed by the ASCII code in Hex. E.g., "~" is replaced by "%7E", "#" by "%23" and so on. Since blank is rather common, it can be replaced by either "%20" or "+" (the "+" character must be replaced by "%2B"). This replacement process is called URL-encoding, and the result is a URL-encoded query string. 

所以这是否意味着我们不能在输入字段中使用%作为值?

+0

你能和调试级别日志尝试这一点,并提供这些日志? – Dancrumb 2013-02-21 14:17:07

回答

1

终于得到了解决,

添加参数在查询字符串我用的JavaScript的encodeURIComponent函数之前。 从W3Schools

The encodeURI() function is used to encode a URI. 
This function encodes special characters, except: ,/? : @ & = + $ # (Use encodeURIComponent() to encode these characters). 

Tip: Use the decodeURI() function to decode an encoded URI. 
1

您正试图对之前步骤中已被URL解码的字符串进行URL解码。这是你的根本原因。

两组验证和失效字符串之间的差异是'&'字符。不能确定为什么与&符号验证的人...可能解析器在到达'%'之前停止,因为'&'被视为分隔符。