我一直在努力使用Spring mvc 3.0.5 sitemesh为网站启用多个ulr-pattern 2.4.2.my容器是tomcat 6.0.26我的pom看起来像这样:
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.14</version>
</dependency>
<dependency>
<groupId>opensymphony</groupId>
<artifactId>sitemesh</artifactId>
<version>2.4.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
我正在使用另一种视图技术,它是应用程序管理站点的ZK。
sitemesh应该照顾/site/*
并保持/admin/*
一切正常,直到本周我想为app.am添加移动wap视图,不提供任何网站重定向类型{ {1}}或m.mysite.com
,我只是使用mysite.mobi
请求映射使spring mvc
指向与/wap/*
相同的控制器和操作。所以我的问题是告诉sitemesh也处理/site/*
。
我的web.xml看起来像这样:
/wap/*
根据coderanch,虽然不是关于sitemesh,但两者都应该有效。我认为自<servlet>
<servlet-name>sitemesh-freemarker</servlet-name>
<servlet-class>freemarker.ext.servlet.FreemarkerServlet</servlet-class>
<init-param>
<param-name>TemplatePath</param-name>
<param-value>/WEB-INF/ui/views</param-value>
</init-param>
<init-param>
<param-name>NoCache</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>ContentType</param-name>
<param-value>text/html; charset=UTF-8</param-value>
<!-- Forces UTF-8 output encoding! -->
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- FreeMaker section -->
<servlet-mapping>
<servlet-name>sitemesh-freemarker</servlet-name>
<url-pattern>*.ftd</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>sitemesh-freemarker</servlet-name>
<url-pattern>*.ftl</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>sitemesh-freemarker</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>sitemesh-freemarker</servlet-name>
<url-pattern>*.dec</url-pattern>
</servlet-mapping>
<!-- End FreeMaker section -->
<!-- Sitemesh -->
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class>
</filter>
<!-- Sitemesh -->
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/site/*</url-pattern> <!--this is decorated-->
<url-pattern>/wap/*</url-pattern> <!--this is not -->
<!--<dispatcher>FORWARD</dispatcher>-->
<!--<dispatcher>REQUEST</dispatcher>-->
</filter-mapping>
<!--this bellow doesn't work as page not decorated-->
<!--<filter-mapping>-->
<!--<filter-name>sitemesh</filter-name>-->
<!--<url-pattern>/wap/*</url-pattern>-->
<!--</filter-mapping>-->
<!-- End of Sitemesh -->
实现siteMeshFilter
这是我的HomeController动作
javax.servlet.Filter
答案 0 :(得分:0)
没关系,我忘了将模式放在decorator.xml
中