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。

  • 相关阅读:
    mysql数据库
    is not in the sudoers file.This incident will be reported
    linux的一些命令
    u盘安装linux(windows7+linux双系统)
    优惠券、礼品卡、礼券
    优惠营销管理
    优惠营销管理
    hdu 1166 线段树单点更新
    hdu 1542 扫描线求矩形面积的并
    hdu 2444 二分图判断与最大匹配
  • 原文地址:https://www.cnblogs.com/zjfjava/p/8624061.html
Copyright © 2011-2022 走看看