Spring 如何在自定义错误页上获取请求的URL
我的申请还有一个问题。 我必须创建自己的404页面,我想在那里写“未找到页面{requestedPage}”,但我不知道如何获得这个值 我使用RequestMapping创建了控制器Spring 如何在自定义错误页上获取请求的URL,spring,Spring,我的申请还有一个问题。 我必须创建自己的404页面,我想在那里写“未找到页面{requestedPage}”,但我不知道如何获得这个值 我使用RequestMapping创建了控制器 @RequestMapping("404") public String handle404(Locale locale, Model model ,HttpServletResponse response, HttpServletRequest request){ ... } 并将web.xml中的此页
@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>
404
/404
我在春季论坛上发现了同样的问题
但是没有回答
我查找了所有HttpSerletRequest方法和字段,但没有找到任何有帮助的方法
有人知道怎么做吗?stackoverflow上已经有人问过这个问题:我想答案就是你要找的答案。Why not
String originalUri=request.getAttribute(RequestDispatcher.FORWARD\u request\u URI)可能重复代码>如建议的那样?