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。

  • 相关阅读:
    项目开源-基于ASP.NET Core和EF Core的快速开发框架
    YoyoGo使用指南
    使用SpringSecurity Oauth2.0实现自定义鉴权中心
    Go语言系列之手把手教你撸一个ORM(一)
    记一次容器CPU高占用问题排查
    Spring Boot系列 八、集成Kafka
    Spring Boot系列:七、 实现Mybatis多数据源切换
    SpringBoot系列:六、集成Swagger文档
    MyBatis系列:二、配置文件详解
    MyBatis系列:一、入门
  • 原文地址:https://www.cnblogs.com/zjfjava/p/8624061.html
Copyright © 2011-2022 走看看