Struts2 filter to solve a simple way of conflict

struts2 filter using FilterDispatcher the url, the default is that all url are filtered, but some of the project is not want to use struts2 url filtering, online search a number of methods

1. Modify web.xml file.

<filter-mapping>

<filter-name> struts2 </ filter-name>

<url-pattern> *. action </ url-pattern>

</ Filter-mapping>

Only to add a filter on. Action suffix of the path is valid, if you need to intercept. Jsp, *. jsp on the line together.

However, whether this extension if the url (eg / demo /) can not be filtered

2. Modify struts2 core jar file in the default.properties

The struts.action.extension = action,,

To struts.action.extension = action, do, jsp,

But I did not change the results after that, I do not know why

3. StrutsPrepareAndExecuteFilter customize a succession of filters will be configured into their own custom filters. (Recommended for this method)

public class ExtendStrutsFilter extends StrutsPrepareAndExecuteFilter {

        @Override
        public void doFilter(ServletRequest req, ServletResponse res,FilterChain chain) throws IOException, ServletException {
                HttpServletRequest request = (HttpServletRequest) req;
                // Not filtered url, can add
                if ("/demo/fileupload".equals(request.getRequestURI())) {
                        //System.out.println(" Use custom filters  ");
                        chain.doFilter(req, res);
                }else{
                        //System.out.println(" Use the default filter  ");
                        super.doFilter(req, res, chain);
                }
        }
}

Modify web.xml

<!-- sturts2 Filter   -->
    <filter>
                <filter-name>struts2</filter-name>
                <!--  Replaced by your own filters   -->
                <filter-class>
                        com.filter.ExtendStrutsFilter
                </filter-class>
        </filter>
        <filter-mapping>
                <filter-name>struts2</filter-name>
                <url-pattern>/*</url-pattern>
        </filter-mapping>

This method is successfully tested

分类:Java 时间:2010-10-15 人气:168
分享到:
blog comments powered by Disqus

相关文章

  • jsp simple log filter 2010-03-29

    Login user information will be saved to the session in the following filters to detect if the user session variable is empty will skip the login page is mandatory index.jsp import java.io.IOException; import javax.servlet.Filter; import javax.servlet

  • Servlet JSP 二重修炼:Filter过滤器 2014-11-11

    原网站:http://www.cnblogs.com/Alandre/p/4090491.html 摘要: 原创出处: http://www.cnblogs.com/Alandre/ 泥沙砖瓦浆木匠 希望转载,保留摘要,谢谢! 真正的朋友就是,当你蒙蔽了所有人的眼睛,也能看穿你真实的样子和心底的痛楚. 前言 好久没写博客了.哈哈~宝刀未老呀,操起笔来准备11.11华华丽丽的来一篇.都说温故知新,这句话绝对正确.按着人的记忆曲线,温故是巩固记忆力的好办法.就像我还是经常翻翻自己写的博客.回头来看看

  • public void testStatementAddBatch () public void testConnCommit () 2011-09-01

    public void testStatementAddBatch() { Connection conn = null; Statement stmt = null; try { conn = getDBConnectionMsSqlBySuperAdmin(); stmt = conn.createStatement(); for(int i = 0; i < 100; i++) { String sql = " sql " + i; stmt.addBatch(sql);

  • Software version suffix Beta, RC, Demo, Build and other representatives of the meaning (reproduced) 2011-10-09

    Software version suffix Beta, RC, Demo, Build and other representatives introduced the meaning of this article reads as follows: With the test windows 7 slowly and promotion, on a simple summary of the system a little bit version: Version Number: V (

  • Bloom filter (Bloom Filter) 2011-01-07

    In daily life, including in the design of computer software, we often have to determine whether an element in a collection. For example, in a word processor, to check whether an English word spelled correctly (that is, to determine whether it is in a

  • Oracle select --------- having conditions where condition filter and filter 2010-06-28

    --------- Having conditions where condition filter and filter rows using the HAVING clause to select the GROUP BY clause HAVING clause to the set of conditions and the SELECT statement with WHERE clause similar to the way interaction. WHERE clause se

  • linux with grep command to filter the contents of the file 2010-08-13

    grep command is very powerful effect, introduced here only use it to filter the contents of the file function. Sign in linux system, type the following command Enter more command to view the contents of the file. Here is the contents of the file, and

  • Filter learning filter 2010-09-21

    ///////// Development of web applications, you can develop multiple filter, These filter can be achieved by one or a group of resources to access WEB intercept In order to achieve some special features. For example, the competence to achieve URL leve

  • (Reserved. Finishing) on the JSP page contentType pageEncoding and the difference between the two properties 2010-10-12

    On the JSP page contentType pageEncoding and the difference between the two properties: pageEncoding jsp file itself is encoded contentType the charset is when the server sends the content to the client encoding JSP to go through two of the "code&quo

  • The Beauty of Mathematics Series 21 - Bloom filter (Bloom Filter) 2010-02-09

    In daily life, including in the design of computer software, we often have to determine whether an element in a collection. For example, in word processing software, you need to check whether an English word spelled correctly (that is, to determine w

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 黔ICP备15002463号-1

processed in 0.317 (s). 12 q(s)