springboot在URL中且已转义时解码%错误

问题描述

版本信息:

服务器版本:Apache Tomcat / 9.0.17
服务器内置:2019年3月13日15:55:27 UTC
服务器编号:9.0.17.0
操作系统名称:Windows 8.1
作业系统版本:6.3
架构:amd64
JVM版本:1.8.0_40-b25

spring-boot-2.1.4
弹簧芯-5.1.6

我有一个这样的html页面:localhost / example / 37%.html
(对不起,我无法以http //开头url,因为编辑页面会自动将其更改为链接,并会在%之后添加25)
访问此网址时,出现错误:HTTP状态400。
应该是,因为%是转义字符。
所以我将网址更改为:localhost / example / 37%25.html。
这次,我收到了一个新错误:

Whitelabel错误页面
该应用程序没有针对/ error的显式映射,因此您将其视为后备。
星期四九月03 09:25:13 CST 2020
发生意外错误(类型=内部服务器错误,状态= 500)。
URLDecoder:转义(%)模式中的非法十六进制字符-对于输入字符串:“。h”

我检查了tomcat控制台,它输出错误消息:

2020-09-03 09:25:12 [http-nio-8080-exec-3] ERROR 
o.s.b.w.s.support.ErrorPageFilter - Forwarding to error page from request [/37%.html] due to exception [URLDecoder: Illegal hex characters in escape (%) pattern - For input string: ".h"]
java.lang.IllegalArgumentException: URLDecoder: Illegal hex characters in escape(%) pattern - For input string: ".h" 
at java.net.URLDecoder.decode(URLDecoder.java:194)  
at org.springframework.web.servlet.resource.PathResourceResolver.isInvalidEncodedPath(PathResourceResolver.java:285)
at org.springframework.web.servlet.resource.PathResourceResolver.isResourceUnderLocation(PathResourceResolver.java:254)

似乎tomcat(或浏览器)已将%25解码为%,但是springboot仍会再次解码%(PathResourceResolver.java)

我不知道这是一个错误问题,还是springboot不允许在网址中添加%的正确方法

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)