zoukankan      html  css  js  c++  java
  • Struts2结合sitemesh3制作网站母版页面

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

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

    QQ截图20140804090613

    添加完毕后,你要配置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>

     

    然后你访问看看:

    QQ截图20140804091114

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

  • 相关阅读:
    sweep line 扫描线模型
    双指针&整数二分思路总结
    ELF文件格式
    flask-migrate数据库迁移出现sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (2059, <NULL>)
    腾讯面试题
    zabbix 调用飞书发送消息
    NFS服务部署
    Linux系统启动
    电商系统nuxt的布局目录代码分享
    电商系统中进行流量控制
  • 原文地址:https://www.cnblogs.com/zhangwei595806165/p/3889355.html
Copyright © 2011-2022 走看看