我在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