代码改变世界

web.xml 配置

2017-03-09 16:26  xiangjune  阅读(149)  评论(0编辑  收藏  举报

1. 配置 servlet

<servlet>
<servlet-name>hello</servlet-name>
<servlet-class>test.HelloWorldHttpServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>hello</servlet-name>
<url-pattern>/helloWorld</url-pattern>
</servlet-mapping>

 

2.配置 Filter

<filter>
<filter-name>authFilter</filter-name>
<filter-class>test.LoginFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>authFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

 

3. 配置异常、错误

<error-page>
<error-code>404</error-code>
<location>/error.jsp</location>
</error-page>


<error-page>
<exception-type>javax.servlet.ServletException</exception-type>
<location>/error.jsp</location>
</error-page>