java - Apache tiles V3 includes in subpage -


i'm trying build web application apache tiles. use apache tiles v3 wild card support.

my tiles.xml looks this:

<?xml version="1.0" encoding="iso-8859-1" ?> <!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="*" template="/resources/tiles/main-layout.jsp">         <put-attribute name="main" value="/resources/templates/{1}.jsp" />         <put-attribute name="head-content" value="" />     </definition>     <definition name="*/*" template="/resources/tiles/main-layout.jsp">         <put-attribute name="main" value="/resources/templates/{1}/{2}.jsp" />         <put-attribute name="head-content" value="" />     </definition>     <definition name="*/*/*" template="/resources/tiles/main-layout.jsp">         <put-attribute name="main" value="/resources/templates/{1}/{2}/{3}.jsp" />         <put-attribute name="head-content" value="" />     </definition> </tiles-definitions> 

i have main page (main-layout.jsp) head section , content section.

head section:

<head>      <link rel="stylesheet" type="text/css" href="${basecss}" />     <link rel="stylesheet" type="text/css" href="${messages}" />     <script src="${jquery}"></script>     <script src="${jqueryui}"></script>     <script src="${jquerycookie}"></script>     <script src="${languagetoggle}"></script>     <script src="${menujs}"></script>     <tiles:insertattribute name="head-content"  /> </head> 

main section:

<section class="main-content">      <tiles:insertattribute name="main" /> </section> 

my main section renders correct. can use spring mvc load via /hello/world , file world.jsp gets loaded, de hello folder.

no want add css files head. question is: how can de world.jsp file?

i tried add tiles attribute , load world.jsp file:

<tiles:putattribute name="head-content">     <spring:url value="/resources/base-theme/css/tables.css" var="tablecss" />     <link rel="stylesheet" type="text/css" href="${tablecss}">    </tiles:putattribute> 

but not work. when google come on same pages, in de tiles.xml every page gets specified, tiles v3 wildcard support not needed anymore. give me hint how done?

please read code below understanding. have created default tiles definition global css , js file. yourpage.jsp extends definition , add 2 files it: yourpage.js , yourpage.css

tiles.xml

<tiles-definitions>     <definition name="app.base" template="/path/to/your/layout.jsp">         <put-attribute name="title" value="not found" />         <put-attribute name="header" value="/web-inf/tiles/header.jsp" />         <put-attribute name="body" value="/web-inf/tiles/body.jsp" />         <put-attribute name="footer" value="/web-inf/tiles/footer.jsp" />         <put-list-attribute name="stylesheets">             <add-attribute value="/static/resources/css/bootstrap.min.css" />                        <add-attribute value="/static/resources/css/global.css" />         </put-list-attribute>         <put-list-attribute name="javascripts">             <add-attribute value="/static/resources/js/jquery-2.1.4.min.js" />             <add-attribute value="/static/resources/js/global.js" />         </put-list-attribute>     </definition>     <definition name="yourpage" extends="app.base">         <put-attribute name="title" value="your page" />         <put-attribute name="body" value="/path/to/your/yourpage.jsp" />         <put-list-attribute name="stylesheets" inherit="true">             <add-attribute value="/static/resources/css/yourpage.css" />         </put-list-attribute>         <put-list-attribute name="javascripts" inherit="true">             <add-attribute value="/static/resources/js/yourpage.js" />         </put-list-attribute>     </definition> </tiles-definitions> 

tiles.jsp

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles"%> <tiles:importattribute name="stylesheets"/> <tiles:importattribute name="javascripts"/>  <!doctype html> <html lang="en"> <head>     <title>         <tiles:insertattribute name="title">         </tiles:insertattribute>     </title>      <!-- stylesheets-->     <c:foreach var="css" items="${stylesheets}">        <link rel="stylesheet" type="text/css" href="<c:url value="${css}"/>">     </c:foreach> </head>  <body>     <header>         <tiles:insertattribute name="header" />     </header>     <div class="body">         <tiles:insertattribute name="body" />     </div>     <footer>         <tiles:insertattribute name="footer" />     </footer>      <!-- scripts-->     <c:foreach var="script" items="${javascripts}">         <script src="<c:url value="${script}"/>"></script>     </c:foreach>  </body> </html> 

hope may of help


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -