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 按出现次数排序
    拼接sql
    java 操作 excel
    jQuery ui 利用 datepicker插件实现开始日期(minDate)和结束日期(maxDate)
    android压力测试命令monkey详解
    java css
    iss 默认上传大小为30 M
    PHP自动生成后台导航网址的最佳方法
    PHP 文件上传的综合实例
    php字符串首字母转换大小写的实例
  • 原文地址:https://www.cnblogs.com/zjfjava/p/8624061.html
Copyright © 2011-2022 走看看