本文整理了Java中javax.servlet.Filter.doFilter()
方法的一些代码示例,展示了Filter.doFilter()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Filter.doFilter()
方法的具体详情如下:
包路径:javax.servlet.Filter
类名称:Filter
方法名:doFilter
[英]The doFilter
method of the Filter is called by the container each time a request/response pair is passed through the chain due to a client request for a resource at the end of the chain. The FilterChain passed in to this method allows the Filter to pass on the request and response to the next entity in the chain.
A typical implementation of this method would follow the following pattern:
chain.doFilter()
), doFilter
方法。传递到此方法的FilterChain允许筛选器将请求和响应传递给链中的下一个实体。chain.doFilter()
)调用链中的下一个实体,代码示例来源:origin: spring-projects/spring-framework
/**
* Actually invoke the delegate Filter with the given request and response.
* @param delegate the delegate Filter
* @param request the current HTTP request
* @param response the current HTTP response
* @param filterChain the current FilterChain
* @throws ServletException if thrown by the Filter
* @throws IOException if thrown by the Filter
*/
protected void invokeDelegate(
Filter delegate, ServletRequest request, ServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
delegate.doFilter(request, response, filterChain);
}
代码示例来源:origin: jenkinsci/jenkins
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
if(position==filters.length) {
// reached to the end
chain.doFilter(request,response);
} else {
// call next
filters[position++].doFilter(request,response,this);
}
}
}.doFilter(request,response);
代码示例来源:origin: jersey/jersey
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
wrappedFilter.doFilter(request, response, chain);
}
代码示例来源:origin: org.springframework/spring-web
/**
* Actually invoke the delegate Filter with the given request and response.
* @param delegate the delegate Filter
* @param request the current HTTP request
* @param response the current HTTP response
* @param filterChain the current FilterChain
* @throws ServletException if thrown by the Filter
* @throws IOException if thrown by the Filter
*/
protected void invokeDelegate(
Filter delegate, ServletRequest request, ServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
delegate.doFilter(request, response, filterChain);
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public void doFilter(final ServletRequest request, final ServletResponse response)
throws IOException, ServletException {
if (this.currentPosition == this.additionalFilters.size()) {
this.originalChain.doFilter(request, response);
}
else {
this.currentPosition++;
Filter nextFilter = this.additionalFilters.get(this.currentPosition - 1);
nextFilter.doFilter(request, response, this);
}
}
}
代码示例来源:origin: jenkinsci/jenkins
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
if(itr.hasNext()) {
// call next
itr.next().doFilter(request, response, this);
} else {
// reached to the end
chain.doFilter(request,response);
}
}
}.doFilter(request,response);
代码示例来源:origin: apache/incubator-druid
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException
{
// If there's already an auth result, then we have authenticated already, skip this.
if (request.getAttribute(AuthConfig.DRUID_AUTHENTICATION_RESULT) != null) {
chain.doFilter(request, response);
} else {
delegate.doFilter(request, response, chain);
}
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Pass the call on to the Filter/Servlet.
*/
@Override
public void doFilter(ServletRequest request, ServletResponse response) throws ServletException, IOException {
if (this.filter != null) {
this.filter.doFilter(request, response, this.nextFilterChain);
}
else {
Assert.state(this.servlet != null, "Neither a Filter not a Servlet set");
this.servlet.service(request, response);
}
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Invoke registered {@link Filter Filters} and/or {@link Servlet} also saving the
* request and response.
*/
@Override
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
Assert.notNull(request, "Request must not be null");
Assert.notNull(response, "Response must not be null");
Assert.state(this.request == null, "This FilterChain has already been called!");
if (this.iterator == null) {
this.iterator = this.filters.iterator();
}
if (this.iterator.hasNext()) {
Filter nextFilter = this.iterator.next();
nextFilter.doFilter(request, response, this);
}
this.request = request;
this.response = response;
}
代码示例来源:origin: jenkinsci/jenkins
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
LOGGER.entering(HudsonFilter.class.getName(), "doFilter");
// this is not the best place to do it, but doing it here makes the patch smaller.
((HttpServletResponse)response).setHeader("X-Content-Type-Options", "nosniff");
// to deal with concurrency, we need to capture the object.
Filter f = filter;
if(f==null) {
// Hudson is starting up.
chain.doFilter(request,response);
} else {
f.doFilter(request,response,chain);
}
}
代码示例来源:origin: org.springframework/spring-web
@Override
public void doFilter(final ServletRequest request, final ServletResponse response)
throws IOException, ServletException {
if (this.currentPosition == this.additionalFilters.size()) {
this.originalChain.doFilter(request, response);
}
else {
this.currentPosition++;
Filter nextFilter = this.additionalFilters.get(this.currentPosition - 1);
nextFilter.doFilter(request, response, this);
}
}
}
代码示例来源:origin: SonarSource/sonarqube
@Override
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
if (iterator == null) {
iterator = filters.iterator();
}
if (iterator.hasNext()) {
iterator.next().doFilter(request, response, this);
} else {
chain.doFilter(request, response);
}
}
代码示例来源:origin: openzipkin/brave
@Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse,
FilterChain filterChain) throws IOException, ServletException {
servletRequest.setAttribute(Call.Factory.class.getName(), callFactory);
delegate.doFilter(servletRequest, servletResponse, filterChain);
}
代码示例来源:origin: apache/shiro
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
if (chain.hasNext()) {
Filter filter = chain.next();
filter.doFilter(request, response, this);
} else if (!originalCalled) {
originalCalled = true;
originalChain.doFilter(request, response);
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
String requestPath = urlPathHelper.getPathWithinApplication(httpRequest);
if (matches(requestPath)) {
this.delegate.doFilter(request, response, filterChain);
}
else {
filterChain.doFilter(request, response);
}
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Pass the call on to the Filter/Servlet.
*/
@Override
public void doFilter(ServletRequest request, ServletResponse response) throws ServletException, IOException {
if (this.filter != null) {
this.filter.doFilter(request, response, this.nextFilterChain);
}
else {
Assert.state(this.servlet != null, "Neither a Filter not a Servlet set");
this.servlet.service(request, response);
}
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Invoke registered {@link Filter Filters} and/or {@link Servlet} also saving the
* request and response.
*/
@Override
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
Assert.notNull(request, "Request must not be null");
Assert.notNull(response, "Response must not be null");
Assert.state(this.request == null, "This FilterChain has already been called!");
if (this.iterator == null) {
this.iterator = this.filters.iterator();
}
if (this.iterator.hasNext()) {
Filter nextFilter = this.iterator.next();
nextFilter.doFilter(request, response, this);
}
this.request = request;
this.response = response;
}
代码示例来源:origin: perwendel/spark
@Override
public void doHandle(
String target,
Request baseRequest,
HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
HttpRequestWrapper wrapper = new HttpRequestWrapper(request);
filter.doFilter(wrapper, response, null);
if (wrapper.notConsumed()) {
baseRequest.setHandled(false);
} else {
baseRequest.setHandled(true);
}
}
代码示例来源:origin: spring-projects/spring-security
@Test
public void httpBasicUnauthorizedOnDefault() throws Exception {
// @formatter:off
loadContext("<http>\n" +
" <intercept-url pattern=\"/**\" access=\"hasRole('USER')\" />\n" +
" <http-basic />\n" +
" </http>\n" +
"\n" +
" <authentication-manager />");
// @formatter:on
this.springSecurityFilterChain.doFilter(this.request, this.response, this.chain);
assertThat(this.response.getStatus()).isEqualTo(HttpServletResponse.SC_UNAUTHORIZED);
assertThat(this.response.getHeader("WWW-Authenticate")).isEqualTo("Basic realm=\"Realm\"");
}
代码示例来源:origin: stagemonitor/stagemonitor
@Test
public void testDontProfileStagemonitorServlet() throws Exception {
Filter filter = new HttpRequestMonitorFilter();
final CallStackElement total = Profiler.activateProfiling("total");
filter.doFilter(new MockHttpServletRequest(), new MockHttpServletResponse(), new MockFilterChain());
Profiler.stop();
assertEquals(0, total.getChildren().size());
}
内容来源于网络,如有侵权,请联系作者删除!