【问题标题】:Sitemesh3 Decorator only works with JSP extensionSitemesh3 装饰器仅适用于 JSP 扩展
【发布时间】:2020-01-18 13:09:48
【问题描述】:

我正在使用 Sitemesh3,我只能使用 JSP 扩展来装饰视图。正常的无扩展操作不会被修饰。

例如:

http://localhost:8080/index[无装饰]

http://locathost:8080/index.jsp [被装饰]

~~

我错过了什么?

=======

sitemesh3.xml

<sitemesh>
    <mapping>
        <path>/*</path>
        <decorator>/WEB-INF/decorators/master.jsp</decorator>
    </mapping>
</sitemesh>

======

web.xml

<filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter>
    <filter-name>sitemesh</filter-name>
    <filter-class>org.sitemesh.config.ConfigurableSiteMeshFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<filter-mapping>
    <filter-name>sitemesh</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

=====

struts.xml

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

    <package name="default" extends="struts-default">
        <action name="index">
            <result>/index.jsp</result>
        </action>
    </package>
</struts>

======

文件结构

webapp
|- WEB-INF
|- |- master.jsp
|- |- sitemesh3.xml
|- index.jsp

【问题讨论】:

    标签: jsp struts2 decorator sitemesh


    【解决方案1】:

    需要像这样更改 Sitemesh filter-mapping

    <filter-mapping>
        <filter-name>sitemesh</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>INCLUDE</dispatcher>
        <dispatcher>ERROR</dispatcher>
    </filter-mapping>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-19
      • 1970-01-01
      • 2016-08-18
      • 1970-01-01
      • 2017-03-06
      • 2020-06-26
      • 2016-07-18
      • 2019-07-20
      相关资源
      最近更新 更多