7

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

我用 RequestMapping 创建了控制器

@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 方法和字段,但没有找到任何可以提供帮助的东西。

有谁知道如何做到这一点?

4

0 回答 0