달력

52024  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

'springMVC'에 해당되는 글 1건

  1. 2011.08.03 [SiteMesh] error-page 와 SiteMesh
1. web.xml 설정
<error-page>
    <error-code>404</error-code>
    <location>/html/error/notFound.html</location>
</error-page>    
<error-page>
    <error-code>500</error-code>
    <location>/error/system.mvc</location>
</error-page>

여기서 404에 해당되는 notFound.html 파일은 정적인 단순 html 파일입니다.
하지만 500에 해당되는 system.mvc 를 SpringMVC 를 사용하는 동적 페이지입니다.

2. servlet.xml 설정
<mvc:view-controller path="/error/system.mvc" view-name="/error/temporarySystemError"/>

/error/system.mvc 에 대해 view-name 은 /error/temporarySystemError 로 정했습니다.

3. decorators.xml 설정
<decorator name="error" page="pageDecorator_error.jsp">
    <pattern>/error/system.mvc</pattern>
</decorator>

/error/system.mvc 로 요청이 오면 pageDecorator_error.jsp 페이지의 데코레이터가 먹도록 설정을 했습니다.

4. pageDecorator_error.jsp 파일
... 중략

<body>

    <page:applyDecorator name="header"/>
    <decorator:body/>

</body>
</html>

page 태그의 applyDecorator 가 먹을 줄 알았는데, 이상하게 먹지 않더군요.
근데 특이한 건 에러 페이지가 아닌 직접 /error/system.mvc 형태로 접속하면 정상적으로 데이터레이터가 먹는 것이었습니다.

5. temporarySystemError.jsp 파일
<div>
어쩌고 저쩌고
<div>


해결방법은 decorators.xml 파일의 url-pattern 을 사용하지 않고 결과 jsp에 decorator 를 직접 적용하는 것이었습니다. 즉 결과 페이지인 temporarySystemError.jsp 파일을 아래처럼 수정한 것이죠.

... 중략

<body>

    <page:applyDecorator name="header"/>
    <div>
    어쩌고 저쩌고
    <div>

</body>
</html>


http://www.java2go.net/blog/205?TSSESSION=1f8421104a0d5b693e30aaea745da9d6 이 글이 도움이 많이 되었습니다.








Posted by fromm0
|