请教JAVA拦截器问题,过滤带有aa前缀的 设置<url-pattern>/aa*</url-pattern> 但是aabb不拦截

如题

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>G</display-name>
  <welcome-file-list>

    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>

    <welcome-file>default.jsp</welcome-file>
    
  </welcome-file-list>
    <filter>
        <filter-name>cccc</filter-name>
        <filter-class>cc</filter-class>
        <async-supported>true</async-supported>
    </filter>
    <filter-mapping>
        <filter-name>cccc</filter-name>
        <url-pattern>/aa*</url-pattern>
    </filter-mapping>
</web-app>

cc.java

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;


public class cc implements Filter {

	@Override
	public void destroy() {
		System.out.println("销毁");
	}

	@Override
	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException {
		System.out.println("1");
		//chain.doFilter(request, response);
		request.getRequestDispatcher("index.jsp").forward(request, response);
		System.out.println("2");
	}

	@Override
	public void init(FilterConfig filterConfig) throws ServletException {
		System.out.println("初始化");
	}

}


石头Sky
浏览 2358回答 0
0回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java