标签:exce 1.0 servlets file war version cat class efi
【须知】
【了解】
【传统 web.xml 参考】
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1"> <!-- Define servlets that are included in the web application --> <servlet> <servlet-name>jack</servlet-name> <servlet-class>sample.Jack</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet> <servlet-name>dog</servlet-name> <servlet-class>sample.Dog</servlet-class> <load-on-startup>2</load-on-startup> </servlet> <servlet-mapping> <servlet-name>jack</servlet-name> <url-pattern>/abc/*</url-pattern> <!-- 目录匹配 --> </servlet-mapping> <servlet-mapping> <servlet-name>dog</servlet-name> <url-pattern>/abc/3</url-pattern> <!-- 绝对匹配 --> </servlet-mapping> <servlet-mapping> <servlet-name>dog</servlet-name> <url-pattern>*.do</url-pattern> <!-- 扩展名匹配 --> </servlet-mapping> <!-- 容器优先查找绝对匹配,然后依次是目录匹配、扩展名匹配,如果有冲突总是取最特定的匹配,也就是路径更长长的 --> <!-- 启动容器就加载 servlet 不是默认行为!!!原因是!@$@$@$@%#$(自己想) --> <error-page> <!-- Throwable 是所有异常与错误的父类 --> <exception-type>java.lang.Throwable</exception-type> <location>/WEB-INF/jsp/exception/common-exception.jsp</location> </error-page> <error-page> <error-code>404</error-code> <location>/WEB-INF/jsp/exception/404-exception.jsp</location> </error-page> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>abc/3</welcome-file> <welcome-file>index.jsp</welcome-file> <!-- 与容器匹配规则不相同,文件名前不能放斜线! --> <!-- 每个目录可能有各自的 index.html !--> <!-- 容器先查 servlet 映射,没有才会找欢迎文件 --> </welcome-file-list> </web-app>
【Head First Servlets and JSP】笔记 26: web 应用部署
标签:exce 1.0 servlets file war version cat class efi
原文地址:http://www.cnblogs.com/xkxf/p/7290831.html