当在一个getParameter上调用HttpServletRequest时,我不时会收到这个错误:
INFO: Character decoding failed. Parameter [SomeParameter] with value [SomeValue] 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.
java.io.CharConversionException: isHexDigit
...为了找到此错误的来源,我想记录完整的请求url,但问题是您无法“识别”抛出的错误,因为它是在getParameter方法中捕获的。在getParameter方法之外,没有引发错误,您可以捕获该错误,然后进行日志记录。
那么,我有什么办法可以自己捕捉到这个编码错误吗?
注意:我知道是什么导致了错误,它是参数中编码的错误%。我只是不知道它是从哪里来的,因为它是源中的一个非常中央的位置。
发布于 2016-01-14 16:24:30
这是Tomcat错误消息。
如果Tomcat不能解析参数,它会将一个特殊的请求属性设置为Boolean.TRUE,您可以使用该属性检测错误的参数:
boolean paramParseFailed =
request.getAttribute("org.apache.catalina.parameter_parse_failed") != null;请注意,这只是在读取了参数之后才设置的,因为Tomcat懒散地填充参数。
https://stackoverflow.com/questions/34794196
复制相似问题