SpringMVC3.1 + sitemesh2.4.1整合

详细参考: http://www.ishang123.com/jishubowen/java/2012-09-29/257.html

web.xml
<?xml version="1.0" encoding="UTF-8"?>  
<web-app version="2.5"    
    xmlns="http://java.sun.com/xml/ns/javaee"    
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee    
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">  
  <servlet>  
        <servlet-name>user</servlet-name>  
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>  
        <load-on-startup>1</load-on-startup>  
    </servlet>  
    <servlet-mapping>  
        <servlet-name>user</servlet-name>  
        <url-pattern>/</url-pattern>  
    </servlet-mapping>  
  
    <filter>  
        <filter-name>sitemesh</filter-name>  
        <filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class>  
    </filter>  
    <filter-mapping>  
        <filter-name>sitemesh</filter-name>  
        <url-pattern>/*</url-pattern>  
    </filter-mapping>  
  
    <filter>  
        <filter-name>SpringCharacterEncodingFilter</filter-name>  
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>  
        <init-param>  
            <param-name>encoding</param-name>  
            <param-value>UTF-8</param-value>  
        </init-param>  
    </filter>  
    <filter-mapping>  
        <filter-name>SpringCharacterEncodingFilter</filter-name>  
        <url-pattern>/*</url-pattern>  
    </filter-mapping>  
</web-app>




decorators.xml
<?xml version="1.0" encoding="UTF-8"?>
<decorators defaultdir="/decorators/">
	<excludes>
		<pattern>/login.jsp</pattern>
		<pattern>/login.js</pattern>
	</excludes>

	<decorator name="main" page="basic.jsp">
		<pattern>/*</pattern>
		<pattern>/*.jsp</pattern>
	</decorator>
</decorators>



WebRoot/decorators/basic.jsp
<%@ page language="java" pageEncoding="UTF-8"%>  
<%@ taglib prefix="decorator" uri="http://www.opensymphony.com/sitemesh/decorator"%>  
<h1>User Manager</h1>  
<hr/>  
<decorator:body/>

你可能感兴趣的:(springMVC)