1

こんにちは私は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.

どこを間違えたのか教えてください

ありがとう)

4

1 に答える 1

2

web.xml にこれらのエントリを入れます。

 <context-param>
  <param-name>org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG</param-name>
  <param-value>/WEB-INF/tile/tiles.xml,/org/apache/tiles/classpath-defs.xml</param-value>
 </context-param>
于 2012-09-05T11:29:41.537 に答える