2009년 05월 04일
struts2 에서 tiles 사용하기
[struts2] tiles 사용하기
web.xml
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>MyApp</display-name>
<listener>
<listener-class>
org.apache.struts2.tiles.StrutsTilesListener
</listener-class>
</listener>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter>
<filter-name>tilesdecoration</filter-name>
<filter-class>org.apache.tiles.web.util.TilesDecorationFilter</filter-class>
<init-param>
<param-name>definition</param-name>
<param-value>blank</param-value>
</init-param>
<init-param>
<param-name>attribute-name</param-name>
<param-value>body</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>tilesdecoration</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>home.action</welcome-file>
</welcome-file-list>
</web-app>
struts.xml
<struts>
<package name="default" extends="struts-default">
<result-types>
<result-type class="org.apache.struts2.views.tiles.TilesResult"
name="tiles">
</result-type>
</result-types>
<action name="home" class="com.tj.actions.HomeAction">
<result>jsp/home.jsp</result>
</action>
</package>
</struts>
tiles.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
"http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
<tiles-definitions>
<definition name="blank" template="/jsp/template/blankLayout.jsp">
<put-attribute name="title" value="my application" />
</definition>
</tiles-definitions>
blankLayout.jsp
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<html>
<head>
<title><tiles:getAsString name="title"/></title>
</head>
<body>
<tiles:insertAttribute name="body" />
</body>
</html>
[출처] [struts2] tiles 사용하기|작성자 rain3k
이 글과 관련있는 글을 자동검색한 결과입니다 [?]
- web.xml 의 초기 설정 by 북극성인
- Struts2 내부구조 by darkmirr
- Basic XML use MVC by 온스토리닷넷
# by | 2009/05/04 10:09 | FRAME WORK | 트랙백 | 핑백(1) | 덧글(0)





☞ 내 이글루에 이 글과 관련된 글 쓰기 (트랙백 보내기) [도움말]
... http://miteff.blogspot.com/2007/03/getting-started-with-struts-2-and-tiles.htmlhttp://darkmirr.egloos.com/1392788 ... more