Wednesday, March 13, 2013

Spring Mvc jsp Exception Page

Web.xml
  
  java.lang.Exception
  /WEB-INF/pages/error.jsp
  
error.jsp
<%@ page language="java" contentType="text/html; charset=EUC-KR" isErrorPage="true"
    pageEncoding="EUC-KR"%>
<%@taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %>





Insert title here


${hello} This is an error page <%= exception %>


HandlerExceptionResolver class
public class SnsHandlerExceptionResolver implements HandlerExceptionResolver

@Override
public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception error) {

     if (request.getRequestURI().contains(".htm")) {
request.setAttribute("javax.servlet.error.exception", error);
request.setAttribute("hello", "hello");
final ModelAndView view = new ModelAndView();
return view;
}

}
If servlet Exception Occured this error.jsp page will called

No comments:

Post a Comment