欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

解决 Tomcat 报错 java.lang.IllegalArgumentException: Invalid character found in method name.

程序员文章站 2022-06-19 12:54:40
解决 Tomcat 报错 java.lang.IllegalArgumentException: Invalid character found in method name.1. 原因2. 解决2.1 添加配置 (推荐)2.2 其他方法 Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level. java.lang.IllegalArgumentException: Invalid ch...

解决 Tomcat 报错 java.lang.IllegalArgumentException: Invalid character found in method name.

 Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level.
 java.lang.IllegalArgumentException: Invalid character found in method name. HTTP method names must be tokens
	at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:414)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:294)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:770)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)


1. 原因

随着 Tomcat 版本的升高, 会检验 URL, 当浏览器访问 URL 时, 若其中带有特殊字符, 如花括号冒号点等等.

2. 解决

2.1 添加配置 (推荐)

conf/catalina.properties 中添加下面内容.

tomcat.util.http.parser.HttpParser.requestTargetAllow=|{}
org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true

conf/server.xml 中的 <Connector> 节点中, 添加 2 个属性:

relaxedPathChars="|{}[],"
relaxedQueryChars="|{}[],"

重启 Tomcat.

2.2 其他方法

  1. 去除 URL 中的特殊字符.
  2. 使用 Post 方法提交数据.
  3. 降低 Tomcat 版本规避此问题.

本文地址:https://blog.csdn.net/YKenan/article/details/111830620

相关标签: 问题解决 tomcat