spring로 검색한 결과 :: 시소커뮤니티[SSISO Community]
 
SSISO 카페 SSISO Source SSISO 구직 SSISO 쇼핑몰 SSISO 맛집
추천검색어 : JUnit   Log4j   ajax   spring   struts   struts-config.xml   Synchronized   책정보   Ajax 마스터하기   우측부분

회원가입 I 비밀번호 찾기


SSISO Community검색
SSISO Community메뉴
[카페목록보기]
[블로그등록하기]  
[블로그리스트]  
SSISO Community카페
블로그 카테고리
정치 경제
문화 칼럼
비디오게임 스포츠
핫이슈 TV
포토 온라인게임
PC게임 에뮬게임
라이프 사람들
유머 만화애니
방송 1
1 1
1 1
1 1
1 1
1

spring로 검색한 결과
등록일:2011-02-17 23:15:49
작성자:
제목:How do I have common error page templates with tiles in a Spring/MVC 3.0 app?


I have a spring MVC/3.0 app using tiles as it's view, this is working fine however I can't figure out how to get the error pages to also use tiles.

I have in my web.xml

<error-page> 
 
<error-code>404</error-code> 
 
<location>/WEB-INF/error/404.jsp</location> 
</error-page> 

which works fine as an ordinary view NOT using tiles, however when I change the location to one of the view names, the view is not found and renders the ordinary error page.

My tiles.xml file for the view contains the following definition

<definition name="404" extends="standardLayout"> 
 
<put-attribute name="body" value="/WEB-INF/error/404.jsp" /> 
</definition> 

I'm configuring tiles through spring as follows:

<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer"> 
 
<property name="definitions"> 
   
<list> 
     
<value>/WEB-INF/**/tiles.xml</value> 
   
</list> 
 
</property> 
</bean> 

I'm suspecting this is all due to the view not coming from spring itself?

1 Answer

 
 

You need to add the "layouted" jsp in your web.xml. Below is the explaination code:

// Your web.xml should look like this: 
<error-page> 
 
<error-code>404</error-code> 
 
<location>/WEB-INF/error/layout-404.jsp</location> 
</error-page> 
 
 
// Your layout-404.jsp should look like this: 
<%@page isELIgnored="false" %> 
<%@page contentType="text/html"%> 
<%@taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %> 
<tiles:insertDefinition name="404" />     
 
 
// Your layout def should look like this: 
<definition name="404" extends="standardLayout"> 
 
<put-attribute name="body" value="/WEB-INF/error/404.jsp" /> 
</definition>