首页 > 代码库 > web.xml 配置
web.xml 配置
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>
web.xml 配置