WEB-INF/web.xml
--------------------------------------------------------------------------------
...
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<error-page>
<error-code>404</error-code>
<location>/error/404.do</location>
</error-page>
</web-app>
--------------------------------------------------------------------------------
ErrorController.java
--------------------------------------------------------------------------------
package x.x.x.controller;
import java.util.Locale;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class ErrorController {
private Logger logger = Logger.getLogger(this.getClass());
@RequestMapping(value = "/error/404")
public String error404(Locale locale, HttpServletRequest request, HttpServletResponse response, HttpSession session) {
return "error/404";
}
}
--------------------------------------------------------------------------------
/WEB-INF/views/error/404.jsp
--------------------------------------------------------------------------------
<%@ page language="java" isErrorPage="true" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<title>Error page</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<button onclick="history.back()">Back to Previous Page</button>
<h1>Page Not Found.</h1><br />
<p><b>Error code:</b> ${pageContext.errorData.statusCode}</p>
<p><b>Request URI:</b> ${pageContext.request.scheme}://${header.host}${pageContext.errorData.requestURI}</p><br />
</body>
</html>
--------------------------------------------------------------------------------
Well if you encounter this, it will be good if you will fix this asap or you will suffer from this. To avoid this kind of incident, avail a website availability monitoring.
답글삭제