zoukankan      html  css  js  c++  java
  • urlrewrite与struts2结合使用基本配置

    1.更改web.xml,,,在struts2拦截器前面添加urlrewrite配置信息,,默认是forward的

        <filter>
            <filter-name>UrlRewriteFilter</filter-name>
            <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
            <!--  设备文件重加载间隔 (0默示随时加载, -1默示不重加载, 默认-1) -->
            <init-param>
                <param-name>logLevel</param-name>
                <param-value>WARN</param-value>
            </init-param>
            <!-- 自定义配置文件的路径,是相对context的路径,(默认位置 /WEB-INF/urlrewrite.xml) -->
            <init-param>
                <param-name>confPath</param-name>
                <param-value>/WEB-INF/urlrewrite.xml</param-value>
            </init-param>
        </filter>
        <filter-mapping>
            <filter-name>UrlRewriteFilter</filter-name>
            <url-pattern>/*</url-pattern>
            <dispatcher>FORWARD</dispatcher>
            <dispatcher>REQUEST</dispatcher>
        </filter-mapping>

    2.看一下struts2的dispatcher是什么,没有的话需要加上一个forward方式,不然没法拦截此请求

        <filter>
            <filter-name>struts2</filter-name>
            <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
        </filter>
        <filter-mapping>
            <filter-name>struts2</filter-name>
            <url-pattern>/*</url-pattern>
            <!-- 因为UrlReWrite默认转发方式为FORWARD,所以要想让你的Struts2过滤器拦截到UrlReWrite转发的请求,必须在filter-mapping加上<dispatcher>FORWARD</dispatcher> -->
            <dispatcher>REQUEST</dispatcher>  
            <dispatcher>FORWARD</dispatcher>  
            <dispatcher>INCLUDE</dispatcher>
        </filter-mapping>

    3.配置urlrewrite.xml

        <rule>
            <note>登录Demo</note>
            <from>/login.html</from>
            <to>/membersLogin/membersLoginAction!membersLogin.action</to>
        </rule>

    通过以上几乎就ok了,若还不成功欢迎交流,QQ群4060038

  • 相关阅读:
    POJ 2892 Tunnel Warfare(树状数组+二分)
    POJ 2886 Who Gets the Most Candies?(树状数组+二分)
    POJ 2492 A Bug's Life(并查集)
    POJ 1182 食物链(并查集)
    POJ 1703 Find them, Catch them(种类并查集)
    TC SRM 582 DIV 2
    函数
    shell进阶--流程
    计划任务 at,cron
    kill命令
  • 原文地址:https://www.cnblogs.com/zhangjianbing/p/8276264.html
Copyright © 2011-2022 走看看