egovFramework 헤더, 푸더 등 레이아웃 Tiles 설정 방법
레이아웃 Tiles 설정 방법
egov-com-servlet.xml 예시
<bean id="tilesViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.tiles3.TilesView" />
<property name="order" value="1" />
</bean>
<!-- Tiles Configurer -->
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/config/egovframework/tiles/common-def.xml</value>
</list>
</property>
</bean>
common-def.xml 파일을 definitions 프로퍼티로 사용하는 tilesConfigurer를 정의합니다.
common-def.xml 예시
<tiles-definitions>
<definition name="baseUser" template="/WEB-INF/jsp/_tiles/user/layout.jsp">
<put-attribute name="header" value="/WEB-INF/jsp/_tiles/user/header.jsp" />
<put-attribute name="left" value="/WEB-INF/jsp/_tiles/user/left.jsp" />
<put-attribute name="footer" value="/WEB-INF/jsp/_tiles/user/footer.jsp" />
</definition>
<definition name="layout/user/*/*" extends="baseUser">
<put-attribute name="content" value="/WEB-INF/jsp/view/user/{1}/{2}.jsp" />
</definition>
<definition name="layout/user/*/*/*" extends="baseUser">
<put-attribute name="content" value="/WEB-INF/jsp/view/user/{1}/{2}/{3}.jsp" />
</definition>
</tiles-definitions>
헤더/푸터 템플릿 layout.jsp를 어떤 View에 적용할지에 대한 URL 패턴을 정의합니다.
Controller 예시
package com.intermorph.cmmn.price.web;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.intermorph.cmmn.base.BaseController;
@Controller
public class IMPriceGuideController extends BaseController {
@RequestMapping(value = "/cmmn/priceGuide/selectList.do")
public ModelAndView selectList(HttpServletRequest req, HttpServletResponse res) throws Exception {
ModelAndView mav = new ModelAndView();
mav.setViewName("layout/user/cmmn/price/priceGuide");
return mav;
}
}
ViewName을 layout/user/*/* URL 패턴에 맞춰서 리턴하는 예시입니다.
/WEB-INF/jsp/view/user/cmmn/price/priceGuide.jsp 파일에 layout.jsp가 적용됩니다.
Leave a comment