问题
I am new to tiles.I have configured my tiles.xml in following way:
<tiles-definitions>
<definition name="baseLayout" template="/template/BaseLayout.jsp">
<put-attribute name="title" value="" />
<put-attribute name="header" value="/template/Header.jsp" />
<put-attribute name="menu" value="/template/Menu.jsp" />
<put-attribute name="body" value="" />
<put-attribute name="footer" value="/template/Footer.jsp" />
</definition>
<definition name="/addCustomer.tiles" extends="baseLayout">
<put-attribute name="title" value="Customer Form" />
<put-attribute name="body" value="/addCustomer.jsp" />
</definition>
</tiles-definitions>
My struts.xml is as follows:
<struts>
<constant name="struts.convention.action.includeJars" value=".*?\.jar(!/|/)?" />
<constant name="struts.convention.action.fileProtocols" value="jar,zip" />
<package name="default" extends="struts-default" namespace="/">
<result-types>
<result-type name="tiles"
class="org.apache.struts2.views.tiles.TilesResult" />
</result-types>
<action name="addCustomer" class="com.adv.web.action.CustomerAction" method="addCustomer">
<result name="addCustomer" type="tiles">/addCustomer.tiles</result>
</action>
</package>
</struts>
I have configured web.xml as follows:
<context-param>
<param-name>
org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG
</param-name>
<param-value>
/WEB-INF/tiles/tiles.xml
</param-value>
</context-param>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
<init-param>
<param-name>actionPackages</param-name>
<param-value>com.adv.web.action</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>
org.apache.struts2.tiles.StrutsTilesListener
</listener-class>
</listener>
I have added struts2-tiles-plugin
in pom.xml
file.
when I am hittng following url: localhost:7001/AddStrutsViewer-1.0/addCustomer I am getting following exception
INFO: Publishing TilesContext for context:
org.apache.struts2.tiles.StrutsWildcardServletApplicationContext
org.apache.tiles.definition.NoSuchDefinitionException: Cannot find definition named 'addCustomer.tiles'
Can anyone figure out the issue?
回答1:
/addCustomer.tiles
should be
addCustomer.tiles
instead
来源:https://stackoverflow.com/questions/50895009/org-apache-tiles-definition-nosuchdefinitionexception-cannot-find-definition-na