org.apache.tiles.definition.NoSuchDefinitionException:找不到名为' addCustomer.tiles'的定义。

时间:2018-06-17 08:33:15

标签: struts2 tiles

我是tiles的新手。我已按以下方式配置了tiles.xml:

<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>

我的struts.xml如下:

<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>

我已按如下方式配置web.xml:

  <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>

我在struts2-tiles-plugin文件中添加了pom.xml

当我按下网址时被点击: localhost:7001/AddStrutsViewer-1.0/addCustomer 我得到了以下异常

      INFO: Publishing TilesContext for context:
      org.apache.struts2.tiles.StrutsWildcardServletApplicationContext
      org.apache.tiles.definition.NoSuchDefinitionException: Cannot find definition named 'addCustomer.tiles'

有人能解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

/addCustomer.tiles

应该是

addCustomer.tiles

代替