📄 facescontextfilter.java
字号:
/* * Copyright 2002-2004 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package de.mindmatters.faces.spring.context.servlet;import java.io.IOException;import javax.faces.context.FacesContext;import javax.servlet.FilterChain;import javax.servlet.ServletException;import javax.servlet.ServletRequest;import javax.servlet.ServletResponse;import org.springframework.web.filter.GenericFilterBean;/** * <strong>{@link javax.servlet.Filter}</strong> implementation that creates * and releases a {@link FacesContext} which contains per-request state * information. Should be used if it is necessary to implement * {@link javax.servlet.Filter}s which want to access the current FacesContext. * <em>This class should be the first Filter in the filter chain.</em> * * @author Andreas Kuhrwahl * */public final class FacesContextFilter extends GenericFilterBean { /** For creating and releasing the {@link FacesContext}. */ private final FacesContextLoader facesContextProvider = FacesContextLoader .getCurrentInstance(); /** * {@inheritDoc} */ public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException { FacesContext facesContext = this.facesContextProvider.initFacesContext( getFilterConfig().getServletContext(), request, response); try { chain.doFilter(request, response); } finally { this.facesContextProvider.releaseFacesContext(facesContext); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -