반응형

400, 401, 404 ... 에러페이지 매핑


location 부분은 경로에 맞게 jsp 파일 생성해서 입력

web,xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<error-page>
    <error-code>401</error-code>
    <location>/error/error.jsp</location>
</error-page>
<error-page>
    <error-code>403</error-code>
    <location>/error/error.jsp</location>
</error-page>
<error-page>
    <error-code>404</error-code>
    <location>/error/404error.jsp</location>
</error-page>
<error-page>
    <exception-type>java.lang.NullPointerException</exception-type>
    <location>/error/error.jsp</location>
</error-page>
<error-page>
    <exception-type>java.lang.Throwable</exception-type>
    <location>/error/error.jsp</location>
</error-page>
<error-page>
    <exception-type>java.lang.Exception</exception-type>
    <location>/error/error.jsp</location>
</error-page>
cs

error,jsp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<%
    out.print("status_code : ");
    out.print(request.getAttribute("javax.servlet.error.status_code"));
    out.print("<br />");
    out.print("<br />");
    out.print("exception_type : ");
    out.print(request.getAttribute("javax.servlet.error.exception_type"));
    out.print("<br />");
    out.print("<br />");
    out.print("message : ");
    out.print(request.getAttribute("javax.servlet.error.message"));
    out.print("<br />");
    out.print("<br />");
    out.print("exception : ");
    out.print(request.getAttribute("javax.servlet.error.exception"));
    out.print("<br />");
    out.print("<br />");
    out.print("request_uri : ");
    out.print(request.getAttribute("javax.servlet.error.request_uri"));
%>
cs


반응형

'IT > 언어' 카테고리의 다른 글

Servlet Encoding Filter  (0) 2014.05.21
정규 표현식 예제  (0) 2014.05.21
Jquery validation  (0) 2014.05.21
tomcat7 SSL 설정  (0) 2014.05.19
[LIB] STRUT2  (0) 2014.05.19

+ Recent posts