requestoverridefilter.java

来自「一个很好的开源项目管理系统源代码」· Java 代码 · 共 56 行

JAVA
56
字号
package net.java.workeffort.webapp.support;import java.io.IOException;import javax.servlet.Filter;import javax.servlet.FilterChain;import javax.servlet.FilterConfig;import javax.servlet.ServletException;import javax.servlet.ServletRequest;import javax.servlet.ServletResponse;import javax.servlet.http.HttpServletRequest;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;/** * Looks like in some containers (ex Resin, WebSphere), request.getRequestURL() * behaves differently than in other containers. Some containers return the URL * of the initial request, while some other containers return the URL of a * forward if any (Ex: url to the tiles page) . This creates problems in the * datagrid library which is used by the application for pagination and needs * the initial URL. This filter should take care of the problem. See * <code>web.xml</code> for configuration information. * @see RequestWrapper * @author Antony Joseph */public class RequestOverrideFilter implements Filter {    private static final Log log = LogFactory            .getLog(RequestOverrideFilter.class);    /**     * {@inheritDoc}     */    public void init(FilterConfig filterConfig) {        if (log.isInfoEnabled())            log.info("RequestOverrideFilter enabled");    }    /**     * {@inheritDoc}     */    public void doFilter(ServletRequest servletRequest,            ServletResponse servletResponse, FilterChain filterChain)            throws IOException, ServletException {        RequestWrapper wrapper = new RequestWrapper(                (HttpServletRequest) servletRequest);        filterChain.doFilter(wrapper, servletResponse);    }    /**     * {@inheritDoc}     */    public void destroy() {        // nothing to destroy    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?