gst*_*low 2 servlets spring-mvc request custom-error-handling
我发送以下http请求:
http://localhost:8081/member/createCompany/getSmallThumbnail/
Run Code Online (Sandbox Code Playgroud)
在服务器端,我遇到了控制器方法:
@RequestMapping("/error")
public String error(Model model, HttpServletRequest request){
if(request.getRequestURI().contains("thumbnail")){
System.out.println("thumbnail accepted");
}
request.toString();
model.addAttribute("message", "page not found");
return "errorPage";
}
Run Code Online (Sandbox Code Playgroud)
在这种方法下,我想知道请求到达的URL。
但是我无法在请求中找到将返回此方法的方法。
请帮助返回我想要的网址。
实际上我没有在Spring MVC应用程序中映射控制器(URL损坏)http://localhost:8081/member/createCompany/getSmallThumbnail/。此url(“ / error”)在web.xml中配置为错误页面。
您的请求已重新发送到/error(可能是为了处理错误)。
如果此框架遵循正常的Servlet错误分配行为,则可以HttpServletRequest.getAttributes()在各种javax.servlet.RequestDispatcher.ERROR_*键下的中找到您的原始请求。
ERROR_EXCEPTION -异常对象ERROR_EXCEPTION_TYPE -异常对象的类型ERROR_MESSAGE -异常消息ERROR_REQUEST_URI -导致错误分配的原始请求uriERROR_SERVLET_NAME -引起错误的servlet的名称ERROR_STATUS_CODE -为此错误分配确定的响应状态代码你想要的是
String originalUri = (String) request.getAttribute(
RequestDispatcher.ERROR_REQUEST_URI)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
615 次 |
| 最近记录: |