如何在自定义错误页面上获取请求的URL

时间:2012-12-11 14:33:15

标签: spring

我的应用程序遇到了下一个问题。 我必须创建自己的404页面,我想在那里写“找不到页面{requestedPage}”,但我不知道如何获得这个值。

我用RequestMapping创建了Controller

@RequestMapping("404")
public String handle404(Locale locale, Model model ,HttpServletResponse response, HttpServletRequest request){
    ...
}

并在web.xml中将此页面设置为404错误页面

<error-page>
    <error-code>404</error-code>
    <location>/404</location>
</error-page>

我在春季论坛上发现了同样的问题 http://forum.springsource.org/showthread.php?87670-Knowing-the-requested-URL-during-a-404 但没有回答

我查找了所有HttpSerletRequest方法和字段,但找不到任何有用的东西。

有谁知道怎么做?

0 个答案:

没有答案