SpringBoot2.0 url中出现特殊符号「带括号{}'"等等」时会抛出400错误
访问
http://127.0.0.1:8080/api?method=taxiong.goods.list¶ms={"page":1,"pageSize":10}
出现了如下错误
2018-08-09 21:39:28.915 INFO 6750 --- [nio-8080-exec-1] o.apache.coyote.http11.Http11Processor : 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.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:479) ~[tomcat-embed-core-8.5.32.jar:8.5.32]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:684) ~[tomcat-embed-core-8.5.32.jar:8.5.32]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-8.5.32.jar:8.5.32]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:800) [tomcat-embed-core-8.5.32.jar:8.5.32]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1471) [tomcat-embed-core-8.5.32.jar:8.5.32]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-8.5.32.jar:8.5.32]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_111]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_111]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.5.32.jar:8.5.32]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_111]
网上找了下,大概是这样解释的:
这个问题是由于Tomcat的新版本中增加了一个新特性,就是严格按照 RFC 3986规范进行访问解析,而 RFC 3986规范定义了Url中只允许包含英文字母(a-zA-Z)、数字(0-9)、-_.~4个特殊字符以及所有保留字符(RFC3986中指定了以下字符为保留字符:! * ’ ( ) ; : @ & = + $ , / ? # [ ])。
解决方案:
① 可以客户端请求时URL encode处理特殊字段
② 改用 post 请求 『由于我这是一个新服务在开发中,所以选用了这种方案』
③ 改 Tomcat 配置文件
http://tomcat.apache.org/tomcat-8.0-doc/config/systemprops.html#Other
官方描述如下
tomcat.util.http.parser.HttpParser. requestTargetAllow
This system property is deprecated. Use the relaxedPathChars and relaxedQueryChars attributes of the Connector instead. These attributes permit a wider range of characters to be configured as valid. A string comprised of characters the server should allow even when they are not encoded. These characters would normally result in a 400 status. The acceptable characters for this property are: |, { , and } WARNING: Use of this option may expose the server to CVE-2016-6816. If not specified, the default value of null will be used.
SpringBoot2.0 url中出现特殊符号「带括号{}'"等等」时会抛出400错误的更多相关文章
- url中的特殊符号含义
1. # 10年9月,twitter改版.一个显著变化,就是URL加入了"#!"符号.比如,改版前的用户主页网址为http://twitter.com/username改版后,就变 ...
- 你知道url中的特殊符号含义么
1.# #代表网页中的一个位置.其右面的字符,就是该位置的标识符.比如,http://www.example.com/index.html#print就代表网页index.html的print位置.浏 ...
- URL中一些特殊符号的替代符
下表中列出了一些URL特殊符号及编码 十六进制值 1.+ URL 中+号表示空格 %2B 2.空格 URL中的空格可以用+号或者编码 %20 3./ 分隔目录和子目录 %2F 4.? 分隔实际的 UR ...
- 从0开始学习 GitHub 系列之「03.Git 速成」
前面的 GitHub 系列文章介绍过,GitHub 是基于 Git 的,所以也就意味着 Git 是基础,如果你不会 Git ,那么接下来你完全继续不下去,所以今天的教程就来说说 Git ,当然关于 G ...
- 从0开始学习 GitHub 系列之「02.加入 GitHub」
转载地址: http://blog.csdn.net/googdev/article/details/52787586 看完昨天的文章「从0开始学习 GitHub 系列之「初识 GitHub」」估计不 ...
- 在Springboot2.0项目中使用Druid配置多数据源
在Springboot出现之前配置数据源以及相关的事物,缓存等内容一直是个繁琐的工作,但是Springboot出现后这些基本都可以靠默认配置搞定,就变得很轻松了.这就是现在推崇模板>配置的原因, ...
- 将SSM架构中原来关于springSecurity3.x版本的写法配迁移到SpringBoot2.0框架中出现的问题解决记
迁移过程中关于这个安全框架的问题很麻烦,springBoot自带的stater中的版本是5.0,原来系统有通过实现"org.springframework.security.authenti ...
- SpringBoot2.0 项目中使用事务
参考博客: SpringBoot开启事务常见坑点 另外注意手动回滚事务需要 (1)在业务层方法上添加注解 @Transactional (2)在需要回滚的地方添加代码: TransactionAspe ...
- IntellJ IDEA2017 springboot2.0.2中读取配置
IDEA 路径 src\main\resources\application.properties 配置文件名称为 application.properties 默认的位置在classpath根目录下 ...
随机推荐
- dependencyManagement、parent与dependencies
本文总结自:https://www.cnblogs.com/feibazhf/p/7886617.html 当我们的项目很多时,为了适应子项目的依赖项使用统一的版本,我们可以创建一个parent项目来 ...
- 初识PHP(一)基础语法
一直准备学习PHP,结果前一段时间总是有事情,耽误了一阵子.现在赶快迎头赶上! 这个系列只是谈谈我对于PHP的一些看法,不是教程性质的.另外我是小白,只是写写随笔,大神求轻拍.本人学习过c .java ...
- ZOJ 2587 Unique Attack(最小割唯一性判断)
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2587 题意:判断最小割是否唯一. 思路: 最小割唯一性的判断是先跑一遍最大 ...
- 最好的移动触摸滑动插件:Swiper
最近在使用的一个移动触摸滑动插件Swiper,功能很强大,跟之前的那个swipe.JS相比,同时支持在PC端滑动,支持上下方向滑动,支持多张图片滑动,支持多屏滑动,凡是你想得到的几乎都可以实现.最近作 ...
- Morgan logger
var logger = require("morgan"); res.render = function(view, options, fn){ options = option ...
- apache允许列目录
vi /etc/httpd/conf.d/welcom.conf <LocationMatch "^/+$"> #Options -Indexes vi /etc ...
- BigDecimalUtils BigDecimal加减乘除
public class BigDecimalUtil { private static int DEF_DIV_SCALE = 10; // 默认精确的小数位 /** * 提供精确的加法运算. * ...
- 9.2 Zynq嵌入式系统调试方法
陆佳华书<嵌入式系统软硬件协同设计实战指南 第2版>这本书中的实例着实浪费了我不少时间.从本书第一个实例我就碰了一鼻子灰.当然显然是自己时新手的原因.首先第一个实验其实真的特别简单,为什么 ...
- Struts2基本使用(三)--数据交互
Struts2中的数据交互 在Struts2中我们不必再使用request.getParameter()这种方式来获取前台发送到服务器的参数. 我们可以在服务器端的Java类中直接声明一个和前台发送数 ...
- [转]设置银行卡密码的个人bug
国庆前去某银行新办了张银行卡,办卡的时候修改了默认的密码.国庆期间要网上购物,结果密码输入3次都错误,所以银行卡被锁定了,只能等国庆后银行上班再去解锁. 国庆结束后跑去银行重置了密码,流程是这样的:1 ...