jar:java archive(java归档)
war: w eb ar chive (web archive)
A war file is just a snapshot of the structure of a web application, in a more portable compressed form (it's actually a jar file). To create a war file is to compress the entire Web application structure (not the Web application name directory, that is, compress from the WEB-INF level).
In the Tomcat container, the filename of the war file becomes the name of the web application.
Configure the welcome file in web.xml:
1 <web-app> 2 <welcome-file-list> 3 <welcome-file>index.html</welcome-file> 4 <welcome-file>default.jsp</welcom-file> //<welcome-file>中的文件不以斜线开头 5 </welcom-file-list> 6 </web-app>
Configure the error page in web.xml:
1 < web-app > 2 < error-page > 3 < exception-type > java.lang.Throwable </ exception-type > // Except for the specific errors below, other errors use this errorPage.jsp page 4 < location > /errorPage.jsp </ location > 5 </ error-page > 6 7 < error-page > 8 < exception-type > java.lang.ArithmeticException </ exception-type > //<exception-type> Must use fully qualified class name9 <location>/arithmeticError.jsp</location> 10 </error-page> 11 12 <error-page> 13 <error-code>404</error-code> //指定错误码 14 <location>/notFoundError.jsp</location> 15 </error-page> 16 </web-app>
Configure Servlet initialization in web.xml:
Use the <load-on-startup> element in DD if you want the servlet to be loaded at deployment time (or when the server restarts), rather than waiting until the first request arrives.
1 < servlet > 2 < servlet-name > KathyOne </ servlet-name > 3 < servlet-class > foo.DeployTestOne </ servlet-class > 4 < load-on-startup > 1 </ load-on-startup > / A value greater than 0 for /<load-on-startup> indicates that the servlet should be initialized when the application is deployed (or when the server is restarted). The smaller the value, the earlier the initialization, e.g. <load-on-startup>1</load-on-startup> is initialized 5 earlier than <load-on-startup>5</load-on-startup> </ servlet >