嗨,我是 Struts2 的新手,我有这样的问题
我用瓷砖写网络应用程序这是我的应用程序的结构
这是我的web.xml
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</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>
<context-param>
<param-name>tilesDefinitions</param-name>
<param-value>/WEB-INF/tile/tiles.xml</param-value>
</context-param>
这是我的tiles.xml
<tiles-definitions>
<definition name="baseLayout" template="/jspf/base_layout/base_layout.jsp">
<put-attribute name="title" value="" />
<put-attribute name="header" value="/jspf/header.jsp" />
<put-attribute name="menu" value="/jspf/menu.jsp" />
<put-attribute name="body" value="" />
<put-attribute name="footer" value="/jspf/footer.jsp" />
</definition>
<definition name="news.tiles" extends="baseLayout">
<put-attribute name="title" value="index.title" />
<put-attribute name="body" value="/jsp/news_list.jsp" />
</definition>
<definition name="create.tiles" extends="baseLayout">
<put-attribute name="title" value="news.add" />
<put-attribute name="body" value="/jsp/add_news.jsp" />
</definition>
<definition name="edit.tiles" extends="baseLayout">
<put-attribute name="title" value="news.edit" />
<put-attribute name="body" value="/jsp/edit_news.jsp" />
</definition>
</tiles-definitions>
那是我的struts.xml
<struts>
<constant name="struts.enable.DynamicMethodInvocation"
value="false" />
<constant name="struts.custom.i18n.resources" value="properties.locale" />
<constant name="struts.devMode" value="false" />
<package name="tiles" extends="struts-default" namespace="/">
<result-types>
<result-type name="tiles"
class="org.apache.struts2.views.tiles.TilesResult" />
</result-types>
<action name="newsList" class="by.bulgak.newsmanagement.action.NewsAction" >
<result type="tiles">news.tiles</result>
</action>
<action name="addNewsForm" class="by.bulgak.newsmanagement.action.AddNewsFormAction">
<result type="tiles">create.tiles</result>
</action>
<action name="editNewsForm" class="by.bulgak.newsmanagement.action.EditNewsFormAction">
<result type="tiles">edit.tiles</result>
</action>
<action name="addNews" class="by.bulgak.newsmanagement.action.AddNewsAction">
<result name="success"></result>
<result name="error"></result>
</action>
<action name="deleteNews" class="by.bulgak.newsmanagement.action.DeleteNewsAction">
<result name="success"></result>
<result name="error"></result>
</action>
<action name="editNews" class="by.bulgak.newsmanagement.action.EditeNewsAction">
<result name="success"></result>
<result name="error"></result>
</action>
<action name="deleteNewsList" class="by.bulgak.newsmanagement.action.DeleteNewsListAction">
<result name="success"></result>
<result name="error"></result>
</action>
</package>
<package name="locale" namespace="/" extends="struts-default">
<action name="locale" class="by.bulgak.newsmanagement.action.LocaleAction">
<result>index.jsp</result>
</action>
</package>
</struts>
当我添加所有瓷砖时就像这样
当我启动我的应用程序并调用 addNews 操作浏览器时,我会看到这个
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.tiles.definition.NoSuchDefinitionException: news.tiles
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:578)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:246)
org.apache.struts2.views.tiles.TilesResult.doExecute(TilesResult.java:105)
org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186)
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:374)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:278)
org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:236)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:236)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:90)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:192)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:511)
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.27 logs.
请告诉我哪里出错了
谢谢)