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
  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of Struts2 filter to solve a simple way of conflict

  • Build flex + spring + blazeds + hibernate application

    Build flex + spring + blazeds + hibernate application First, set up the project blazeds 1, will blazeds.war extract to a directory, such as: myflex /; 2, set up java works were such as: MyFlex, in the orientation of selection create project from exis ...

  • Hibernate connection pool configuration

    Hibernate connection pool configuration <! - Jdbc -> <property name="connection.driver_class"> oracle.jdbc.driver.OracleDriver </ property> <property name="connection.url"> jdbc: oracle: thin: @ 10.203.14.132:15

  • hibernate generic generic DAO

    package org.lzpeng.dao; import java.io.Serializable; import java.util.List; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.criterion.Criterion; import org.springside.modules.orm.hibernate.Page; /** * * @version 2009-1-10 *

  • Spring2.0 + hibernate3.1 + log4j + mysql demo

    applicationContext.xml Non-attachment jar package, necessary friends can send an email to todd.liangt @ gmail.com

  • Struts2 + hibernate + spring problem user log in

    dao layer services layer action jsp <tr> <td align="center"> <b> user name: </ b> </ td> <td> <s: textfield name = "czyNumber" cssClass = "textstyle" theme = "simple" size = &q

  • Hibernate secondary cache

    Hibernate cache: 2-bit cache, also known as process-level cache or SessionFactory level cache, secondary cache can be shared by all of the session Cache configuration and the use of: Will echcache.xml (the document code in hibernate package directory ...

  • Hibernate's lazy strategy

    hibernate Lazy strategy can be used in: <class> tag, it can be true / false Tags can <PROPERTY> values true / false type of necessary tools to enhance <set> <list> can tag values true / false / extra <many-to-one> <on ...

  • Great collection of java interview topics

    1, object-oriented features of what has 1. Abstract: Abstract is that it has overlooked a subject has nothing to do with the current goal of those aspects in order to more fully with the current objectives of the attention-related aspects. Abstract does n

  • spring struts2.0 hibernate bug killer 1

    exception There is no Action mapped for namespace / and action name checkLogin. - [Unknown location] com.opensymphony.xwork2.DefaultActionProxy.prepare (DefaultActionProxy.java: 186) org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy ...

blog comments powered by Disqus
Recent
Recent Entries
Tag Cloud
Random Entries