java.lang.IllegalArgumentException: Invalid character found in the request target. The valid charact

在项目中使用的tomcat是apache-tomcat-8.0.41,在完成后台逻辑后,前台js发起GET请求,报400错误,

$http.get('/test/getInfo?source='+source)

java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986

有这个报错信息可以知道是参数不合法,但是source我在前台做了处理

source本身只是json格式,

{"entityName":"","componentEntityName":"ZZZ"}

 

我通过JSON.stringify将其转化为string格式

"{"entityName":"","componentEntityName":"ZZZ"}"

貌似这样之后,后台不是识别这个格式。

在网上查了一些资料,觉得这部分说的不错

This behavior is introduced in all major Tomcat releases: Tomcat 7.0.73, 8.0.39, 8.5.7 For a quick fix, you can downgrade to one of older versions or set requestTargetAllow option Based on changelog, those changes could affect this behavior: Tomcat 8.5.3: Ensure that requests with HTTP method names that are not tokens (as required by RFC 7231) are rejected with a 400 response Tomcat 8.5.7: Add additional checks for valid characters to the HTTP request line parsing so invalid request lines are rejected sooner.downgrade to one of older versions or set requestTargetAllow option Based on changelog, those changes could affect this behavior: Tomcat 8.5.3: Ensure that requests with HTTP method names that are not tokens (as required by RFC 7231) are rejected with a 400 response Tomcat 8.5.7: Add additional checks for valid characters to the HTTP request line parsing so invalid request lines are rejected sooner.


大意就是说tomcat的一些版本会对请求url中的字符进行检查,不符合要求的会返回400错误

 

解决的方法是换成旧的版本或者设置

requestTargetAllow 

 

后面将tomcat换成apache-tomcat-8.0.37,问题解决。

 


 

 


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值