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

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

    <servlet>
    <servlet-name>validateAuth</servlet-name>
    <servlet-class>com.testdemo.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.testdemo.validate.control.ValidateControl</servlet-class>
    </servlet>
    
    <servlet-mapping>
    <servlet-name>validateAuth</servlet-name>
    <url-pattern>/*</url-pattern>
    </servlet-mapping>

 

posted @ 2016-03-23 10:41  苦涩泪滴  阅读(1220)  评论(0编辑  收藏  举报