本文主要是介绍异常The valid characters are defined in RFC 7230 and RFC 3986,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
GET请求添加了JSON参数值出现该异常
java.lang.IllegalArgumentException: Invalid character found in the request target
The valid characters are defined in RFC 7230 and RFC 3986
原因:
tomcat8不允许URL中出现"[]"字符
解决方案:
方案1:对参数进行UrlEncode
方案2:改为post请求
方案3:tomcat降级(没试,不推荐)
方案4:修改tomcat配置,忽略特殊字符(没试)
方案5:springboot,jar包部署,启动类添加如下代码,tomcat忽略特殊字符
@Beanpublic ConfigurableServletWebServerFactory webServerFactory() {TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();factory.addConnectorCustomizers((TomcatConnectorCustomizer) connector -> connector.setProperty("relaxedQueryChars", "|{}[]\\"));return factory;}
这篇关于异常The valid characters are defined in RFC 7230 and RFC 3986的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!