【问题标题】:Struts2 (2.3.1.2) and Sitemesh 2.3 - exclusions not workingStruts2 (2.3.1.2) 和 Sitemesh 2.3 - 排除不起作用
【发布时间】:2012-05-20 08:29:59
【问题描述】:

有人可以帮我解决如何排除子窗口的装饰吗?这是我的代码:

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Hello World Struts 2 Maven</display-name>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>

     <listener>
        <listener-class>org.apache.struts2.dispatcher.ng.listener.StrutsListener</listener-class>
    </listener>

    <!--Filters  -->  

    <filter>
        <filter-name>struts-cleanup</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
    </filter>
    <filter>
        <filter-name>struts-prepare</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter</filter-class>
    </filter>
    <filter>
        <filter-name>struts-execute</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter</filter-class>
    </filter>
    <filter>
        <filter-name>sitemesh</filter-name>
        <filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>struts-prepare</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
    </filter-mapping>
    <filter-mapping>
        <filter-name>sitemesh</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
    </filter-mapping>
    <filter-mapping>
        <filter-name>struts-execute</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
    </filter-mapping>
    <filter-mapping>
        <filter-name>struts-cleanup</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
    </filter-mapping>

</web-app>

struts.xml:

<struts>

    <constant name="struts.devMode" value="true" />

    <package name="basicstruts2" extends="struts-default">

        <!-- If no class attribute is specified the framework will assume success and 
        render the result index.jsp -->
        <!-- If no name value for the result node is specified the success value is the default -->
        <action name="index">
            <result>/index.jsp</result>
        </action>
              <action name="child3">
            <result>/WEB-INF/popUp/Test.jsp</result>
        </action>

        <!-- If the URL is hello.action the call the execute method of class HelloWorldAction.
        If the result returned by the execute method is success render the HelloWorld.jsp -->
        <action name="hello" class="org.apache.struts.helloworld.action.HelloWorldAction" method="execute">
            <result name="success">/HelloWorld.jsp</result>
        </action>

    </package>

</struts>

装饰器.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<decorators defaultdir="/decorators">
    <excludes>

        <pattern>/WEB-INF/popUp/Test.jsp</pattern>
        <pattern>/popUp/Test.jsp</pattern>
        <pattern>child3.html</pattern>
        <pattern>child3</pattern>
        <pattern>/default/child3</pattern>
        <pattern>/default/child3.html</pattern>
    </excludes> 
    <decorator name="main" page="layout.jsp">
        <pattern>/*</pattern>
    </decorator>
    <decorator name="panel" page="panel.jsp" />
</decorators>

我已经在这个任务上花费了 2 天时间,但还没有成功。任何人都可以帮助或指向我的一些链接吗?

问候, 纳齐尔

【问题讨论】:

    标签: struts2 sitemesh


    【解决方案1】:

    我解决了这个问题。我添加了 struts2-sitemesh 插件并遵循配置 web xml 的文档。现在我的装饰器运行良好。

    【讨论】:

      猜你喜欢
      • 2011-01-26
      • 2010-12-19
      • 2012-09-22
      • 2010-11-13
      • 2011-06-20
      • 2017-02-25
      • 2012-01-08
      • 1970-01-01
      • 2014-11-06
      相关资源
      最近更新 更多