码迷,mamicode.com
首页 > Web开发 > 详细

Struts2结合sitemesh3制作网站母版页面

时间:2014-08-04 10:41:46      阅读:318      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   java   使用   io   文件   2014   

上一篇文章介绍了sitemesh3的使用,这篇文章来介绍如何结合struts2来配置和使用sitemesh,具体的如何使用sitemesh3我就不讲解了,这个你们可以看看我的上一篇博客。

首先你要添加struts和sitemesh相关的jar包:

bubuko.com,布布扣

添加完毕后,你要配置web.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    id="WebApp_ID" version="3.0">
    <!--用来消除sitemesh 拦截器 Struts2拦截器的冲突 使之兼容 -->
    <filter>
        <filter-name>struts-cleanup</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
    </filter>

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

    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>struts-cleanup</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

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

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

    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

</web-app> 

 

配置好了之后要配置struts.xml文件:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
    "http://struts.apache.org/dtds/struts-2.3.dtd">

<struts>

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

   <package name="aboutme" extends="struts-default">
        <action name="AboutMe"
            class="zw.hellozw.action.AboutMeAction">
            <result>/AboutMe.jsp</result>
        </action>
        <!-- Add actions here -->
    </package>

</struts>

 

然后你访问看看:

bubuko.com,布布扣

有什么问题可以发送我的常用邮箱:zhangwei900808@126.com,或者qq:1576410833。

Struts2结合sitemesh3制作网站母版页面,布布扣,bubuko.com

Struts2结合sitemesh3制作网站母版页面

标签:style   blog   http   java   使用   io   文件   2014   

原文地址:http://www.cnblogs.com/zhangwei595806165/p/3889355.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!