Tiles 설정에서 Wildcard로 패턴 만들기 

    tiles.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE tiles-definitions PUBLIC
           "-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN"
           "http://tiles.apache.org/dtds/tiles-config_3_0.dtd">
    <tiles-definitions>
      <definition name="notice.*" template="/WEB-INF/view/customer/inc/layout.jsp">
        <put-attribute name="title" value="공지사항" />
        <put-attribute name="header" value="/WEB-INF/view/inc/header.jsp" />
        <put-attribute name="visual" value="/WEB-INF/view/customer/inc/visual.jsp" />
        <put-attribute name="aside" value="/WEB-INF/view/customer/inc/aside.jsp" />
        <put-attribute name="body" value="/WEB-INF/view/customer/notice/{1}.jsp" />
        <put-attribute name="footer" value="/WEB-INF/view/inc/footer.jsp" />
      </definition>
    </tiles-definitions>

     

    Root에 있는 index 페이지에 header footer 붙이기

    root에 있는 index.jsp복사 붙여넣기

    이름을 layout으로 변경

     

    main에 있던 내용은 index.jsp에 붙여 넣기

    layout.jsp

    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
    <%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>    
    <!DOCTYPE html>
    <html>
    
    <head>
        <title>예제</title>
        <meta charset="UTF-8">
        <title>공지사항목록</title>
    
        <link href="/css/layout.css" type="text/css" rel="stylesheet" />
        <link href="/css/index.css" type="text/css" rel="stylesheet" />
        <script>
        
        </script>
    </head>
    
    <body>
        <!-- header 부분 -->
    	 <tiles:insertAttribute name="header" />
       
    
        <!-- --------------------------- <body> --------------------------------------- -->
    	<tiles:insertAttribute name="main" />
    
    
    
        <!-- ------------------- <footer> --------------------------------------- -->
    	<tiles:insertAttribute name="footer" />
    	
    
    
        
    </body>
    
    </html>

     

    tiles.xml

     

    IndexController.java

     

    tiles.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE tiles-definitions PUBLIC
           "-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN"
           "http://tiles.apache.org/dtds/tiles-config_3_0.dtd">
    <tiles-definitions>
      <definition name="root.*" template="/WEB-INF/view/inc/layout.jsp">
        <put-attribute name="title" value="공지사항" />
        <put-attribute name="header" value="/WEB-INF/view/inc/header.jsp" />
        <put-attribute name="body" value="/WEB-INF/view/{1}.jsp" />
        <put-attribute name="footer" value="/WEB-INF/view/inc/footer.jsp" />
      </definition>
        <definition name="notice.*" template="/WEB-INF/view/customer/inc/layout.jsp">
        <put-attribute name="title" value="공지사항" />
        <put-attribute name="header" value="/WEB-INF/view/inc/header.jsp" />
        <put-attribute name="visual" value="/WEB-INF/view/customer/inc/visual.jsp" />
        <put-attribute name="aside" value="/WEB-INF/view/customer/inc/aside.jsp" />
        <put-attribute name="body" value="/WEB-INF/view/customer/notice/{1}.jsp" />
        <put-attribute name="footer" value="/WEB-INF/view/inc/footer.jsp" />
      </definition>
    </tiles-definitions>

     

    • 네이버 블러그 공유하기
    • 네이버 밴드에 공유하기
    • 페이스북 공유하기
    • 카카오스토리 공유하기
    loading