我在我的SpringMVC项目中实现了sitemesh3,并得到了404异常

我在我的SpringMVC项目中实现了sitemesh3,并得到了404异常,spring,templates,spring-mvc,sitemesh,Spring,Templates,Spring Mvc,Sitemesh,我在我的SpringMVC项目中实现了sitemesh3,并得到了404异常。我现在正在学习本教程,问题是我正在将jsp放在视图文件夹中的Web Inf中,所以我应该在decorator标记中的sitemesh3.xml中给出什么路径。我尝试了很长时间,但部署时获得了404….这对我很有用: decorators.xml: <decorators defaultdir="/WEB-INF/decorators"> <decorator name="login" page

我在我的SpringMVC项目中实现了sitemesh3,并得到了404异常。我现在正在学习本教程,问题是我正在将jsp放在视图文件夹中的Web Inf中,所以我应该在decorator标记中的sitemesh3.xml中给出什么路径。我尝试了很长时间,但部署时获得了404….

这对我很有用:

decorators.xml:

<decorators defaultdir="/WEB-INF/decorators">
    <decorator name="login" page="login_master.jsp">
        <pattern>/login*</pattern>
    </decorator>
    <decorator name="none" page="none.jsp">
        <pattern>/report*</pattern>
    </decorator>
    <decorator name="master" page="master.jsp">
        <pattern>/*</pattern>
    </decorator>
</decorators>

/登录*
/报告*
/*
None.jsp:

<html>
    <head>
        <title>
            <decorator:title />
        </title>
        <decorator:head />
    </head>
    <body>
        <decorator:body />
    </body>
</html>

这对我很有用:

decorators.xml:

<decorators defaultdir="/WEB-INF/decorators">
    <decorator name="login" page="login_master.jsp">
        <pattern>/login*</pattern>
    </decorator>
    <decorator name="none" page="none.jsp">
        <pattern>/report*</pattern>
    </decorator>
    <decorator name="master" page="master.jsp">
        <pattern>/*</pattern>
    </decorator>
</decorators>

/登录*
/报告*
/*
None.jsp:

<html>
    <head>
        <title>
            <decorator:title />
        </title>
        <decorator:head />
    </head>
    <body>
        <decorator:body />
    </body>
</html>

我成功地让它在sitemesh3+spring mvc上运行。装饰器可以毫无问题地放在WEB-INF中

我的目录结构如下

webapp/WEB-INF$ tree
.
├── enable-jmx.xml
├── lnramirez-servlet.xml
├── sitemesh3.xml
├── urlrewrite.xml
├── views
│   ├── about.jsp
│   ├── blog
│   │   └── list.jsp
│   ├── defaultdecorator.jsp
│   └── home.jsp
└── web.xml
我的sitemesh3配置

$ cat sitemesh3.xml 
<?xml version="1.0" encoding="MacRoman"?>
<sitemesh>
  <mapping path="/*" decorator="/WEB-INF/views/defaultdecorator.jsp"/>
</sitemesh>
$cat sitemesh3.xml
还有我的web.xml

<filter>
    <filter-name>sitemesh</filter-name>
    <filter-class>org.sitemesh.config.ConfigurableSiteMeshFilter</filter-class>
</filter>

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

<filter>
    <filter-name>HiddenMethodFilter</filter-name>
    <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
</filter>

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

<filter>
    <filter-name>UrlRewriteFilter</filter-name>
    <filter-class>
        org.tuckey.web.filters.urlrewrite.UrlRewriteFilter
    </filter-class>
</filter>

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

网站
org.sitemesh.config.ConfigurableSiteMeshFilter
网站
/*
隐藏方法过滤器
org.springframework.web.filter.hiddenhttmpmethodfilter
隐藏方法过滤器
/*
URL重写过滤器
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter
URL重写过滤器
/*
小心,如果你像我一样使用UrlRewriteFilter,你可能会遇到和我一样的麻烦。您必须将可配置SiteMeshFilter放在其他筛选器之前


它对我很有用

我成功地使它在sitemesh3+spring mvc上工作。装饰器可以毫无问题地放在WEB-INF中

我的目录结构如下

webapp/WEB-INF$ tree
.
├── enable-jmx.xml
├── lnramirez-servlet.xml
├── sitemesh3.xml
├── urlrewrite.xml
├── views
│   ├── about.jsp
│   ├── blog
│   │   └── list.jsp
│   ├── defaultdecorator.jsp
│   └── home.jsp
└── web.xml
我的sitemesh3配置

$ cat sitemesh3.xml 
<?xml version="1.0" encoding="MacRoman"?>
<sitemesh>
  <mapping path="/*" decorator="/WEB-INF/views/defaultdecorator.jsp"/>
</sitemesh>
$cat sitemesh3.xml
还有我的web.xml

<filter>
    <filter-name>sitemesh</filter-name>
    <filter-class>org.sitemesh.config.ConfigurableSiteMeshFilter</filter-class>
</filter>

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

<filter>
    <filter-name>HiddenMethodFilter</filter-name>
    <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
</filter>

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

<filter>
    <filter-name>UrlRewriteFilter</filter-name>
    <filter-class>
        org.tuckey.web.filters.urlrewrite.UrlRewriteFilter
    </filter-class>
</filter>

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

网站
org.sitemesh.config.ConfigurableSiteMeshFilter
网站
/*
隐藏方法过滤器
org.springframework.web.filter.hiddenhttmpmethodfilter
隐藏方法过滤器
/*
URL重写过滤器
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter
URL重写过滤器
/*
小心,如果你像我一样使用UrlRewriteFilter,你可能会遇到和我一样的麻烦。您必须将可配置SiteMeshFilter放在其他筛选器之前


它对我有用

我使用的是sitemesh3,我使用的是sitemesh3.xml,而不是decorators.xml。您是否在web.xml中添加了此筛选器:sitemesh com.opensymphony.module.sitemesh.filter.PageFilter sitemesh/*Kevin此配置用于简单的sitemesh,我使用的是sitemesh 3,因此对我没有用处。我在我的问题中放置了一个链接,请参考以了解我的问题。我使用的是sitemesh3,我有sitemesh3.xml而不是decorators.xml。您是否在web.xml中添加了此筛选器:sitemesh com.opensymphony.module.sitemesh.filter.PageFilter sitemesh/*此配置用于简单sitemesh,我正在使用sitemesh3,因此它对我没有用处。我在我的问题中放置了一个链接,请参考该链接以了解我的问题。