如何为特定视图定义切片定义

时间:2017-11-15 07:31:15

标签: spring-mvc tiles apache-tiles

所以我的tile定义如下所示,我想知道如何管理它以在特定视图上显示特定模板: 我想要默认模板ist" commonPage"并且例如" / MONITOR1"返回值我希望应用emptyTemplate。

<tiles-definitions>
  <definition name="commonPage" template="/WEB-INF/tiles/layouts/topmenulayout.jsp">
    <put-attribute name="header" value="/WEB-INF/tiles/jsp/header.jsp" />
    <put-attribute name="menu" value="/WEB-INF/views/menu.jsp" />
    <put-attribute name="footer" value="/WEB-INF/tiles/jsp/footer.jsp" />
  </definition>

  <definition name="emptyPage" template="/WEB-INF/tiles/layouts/emptylayout.jsp">
  </definition>


  <!-- Views ending in "Dialog" have no header, menu or      -->
  <!-- footer. Useful for creating jQuery popup dialogs.     -->
  <definition name="*/*Dialog" template="/WEB-INF/views/{1}/{2}Dialog.jsp" />
  <definition name="*Dialog" template="/WEB-INF/views/{1}Dialog.jsp" />

  <!-- All other views get the header, menu and footer tiles. -->
  <!-- I want commonPage as default template, and e.g. for "/Monitor1" return value I want the emptyLayout       -->

  <definition name="*" extends="commonPage">
    <put-attribute name="body" value="/WEB-INF/views/{1}.jsp" />
  </definition>
</tiles-definitions>

1 个答案:

答案 0 :(得分:0)

解决它很容易。 我添加了以下定义,它按照我希望的方式工作:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<form name="F">
  <input type="text" name="gword" class="cword">
  <!--<input type="text" name="t" class="in2">-->
  <input type="button" name="b" value="do" class="cclick">
  <div id="dword"></div>
</form>