绕过/*,web.xml直接访问jsp【转】

时间:2021-04-10 17:13:25

web.xml中如果配置了/* 全匹配,那么不能用servet去响应页面返回了,因为全都被会/*拦截.

    <servlet>
    <servlet-name>validateAuth</servlet-name>
    <servlet-class>com.isoftstone.validate.control.ValidateControl</servlet-class>
    </servlet>
    
    <servlet-mapping>
    <servlet-name>validateAuth</servlet-name>
    <url-pattern>/*</url-pattern>
    </servlet-mapping>

 

 

所以这个时候我们可以使用 

<jsp-file>/jsp/index.jsp</jsp-file> 直接通过web.xml配置直连jsp页面.
    <servlet>
    <servlet-name>jsp1</servlet-name>
    <jsp-file>/jsp/index.jsp</jsp-file>
    </servlet>
    
    <servlet-mapping>
    <servlet-name>jsp1</servlet-name>
    <url-pattern>/jsp/index.jsp</url-pattern>
    </servlet-mapping>
    
    
    <servlet>
    <servlet-name>validateAuth</servlet-name>
    <servlet-class>com.isoftstone.validate.control.ValidateControl</servlet-class>
    </servlet>
    
    <servlet-mapping>
    <servlet-name>validateAuth</servlet-name>
    <url-pattern>/*</url-pattern>
    </servlet-mapping>