更新时间:2023-12-04 16:22:04
我不能在Tomcat 6.0.29上重现您的问题。事情还有更多。也许链中的过滤器正在对请求对象做一些事情?
I can't reproduce your problem on Tomcat 6.0.29. There's more at matter. Maybe a Filter in the chain which is doing something with the request object?
无论如何,这是一个单一JSP的 SSCCE :
Anyway, here's a SSCCE in flavor of a single JSP:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test</title>
</head>
<body>
<p><a href="?url=http%3A%2F%2Fwww.site.com%3Fparam1%3D1%26param2%3D2">click here</a>
<p>URL: ${param.url}
</body>
</html>
Copy'n'paste'n'run并点击链接。在这里,我看到以下结果:
Copy'n'paste'n'run it and click the link. Right here I see the following result:
点击这里
click here
URL: http://www.site.com?param1=1¶m2=2
使用像这样的简单servlet可以重现这一点,它可以直接由浏览器地址栏调用:
The same is reproducible with a simple servlet like this which is invoked directly by browser address bar:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.getWriter().write(request.getParameter("url"));
}
顺便说一句,Tomcat配置为 URIEncoding = HTTP连接器中的UTF-8
,但即使使用 ISO-8859-1
(这是默认值),行为也是-as这个特殊情况 - 相同。
Tomcat is by the way configured with URIEncoding="UTF-8"
in HTTP connector, but even with ISO-8859-1
(which is the default), the behaviour is -as expected in this particular case- the same.