我在Tomcat上运行基于Spring框架的Web应用程序。我的要求是,任何来到服务器的请求都应该到达一个servlet。所以我的conf/web.xml中作了如下配置HttpServletRequest的getRequestURL()不返回确切的URL
<error-page>
<error-code>404</error-code>
<location>/displayMsg.do</location>
</error-page>
因此,当用户访问http://myhost/xyz,request.getRequestURL()返回 http://myhost/displayMsg.do
我认为对于requestURL的唯一原因()返回这个网址是因为我所做的错误页面配置。可能是因为tomcat覆盖这个url到这个字符串。
在这种情况下可以得到确切的URL吗? 请帮忙
的可能重复[JSP/Servlet的HTTP 404错误处理] (http://stackoverflow.com/questions/3336501/jsp-servlet-http-404-error-handling) – BalusC 2011-02-11 13:50:48