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。

  • 相关阅读:
    button标签和input button
    获取select标签的值
    window.loaction和window.location.herf
    数组重复计数,对象方法
    js对象详解
    面试经典题型整理
    一些js小知识点整理
    事件委托能够优化js性能
    网页加载的一般顺序
    http状态码
  • 原文地址:https://www.cnblogs.com/zjfjava/p/8624061.html
Copyright © 2011-2022 走看看