zoukankan      html  css  js  c++  java
  • Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986

    在操作前台向后台传表单数值的时候,操作失败,DEBUG模式下控制台输出报错信息如下:

    信息: Error parsing HTTP request header
    Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.
    java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986
    at org.apache.coyote.http11.InternalAprInputBuffer.parseRequestLine(InternalAprInputBuffer.java:235)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1028)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2549)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2538)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)

     tomcat版本:7.0.68

    原因:由于tomcat的新版本增加了一个新特性,就是严格按照 RFC 3986规范进行访问解析,而 RFC 3986规范定义了Url中只允许包含英文字母(a-zA-Z)、数字(0-9)、-_.~4个特殊字符以及所有保留字符(RFC3986中指定了以下字符为保留字符:! * ’ ( ) ; : @ & = + $ , / ? # [ ])。

    所以解决这个问题的办法有几个:要么,把非保留字字符做转义,要么就是使用保留字字符,要么就是换比较低一点的tomcat版本。

    附:网上找了几个方法:如下

    在tomcat目录conf/catalina.properties最后面添加

    tomcat.util.http.parser.HttpParser.requestTargetAllow=|{}

    或者:

    org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true

    无效,暂时采用替换低版本tomcat。

  • 相关阅读:
    C++虚函数机制(转)
    C/C++中extern关键字详解(转)
    (转)Javascript定义类(class)的三种方法
    使用HtmlAgilityPack实现对网页内容的抓取
    (转)Lucene Document getBoost(float) 和 setBoost(float)
    (转)Ajax中Get请求与Post请求的区别
    (转)Lucene.net实现自定义排序
    Lucene.net基本功能核心代码
    (转)使用Lucene.Net实现全文检索
    C#将html table 导出成excel
  • 原文地址:https://www.cnblogs.com/zjfjava/p/8624061.html
Copyright © 2011-2022 走看看