第17周 第3章Servlet开发应用实践 ---Servlet启动时加载与错误页面设置
在web.xml 中加入这些数据,启动时加载,是参数,是优先级
<servlet>
<servlet-name>initTable</servlet-name>
<servlet-class>com.imooc.servlet.startup.InitTableServlet</servlet-class>
<init-param>
<param-name>database</param-name>
<param-value>db02</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet>
<servlet-name>import</servlet-name>
<servlet-class>com.imooc.servlet.startup.ImportServlet</servlet-class>
<init-param>
<param-name>file</param-name>
<param-value>c:/tmp/demo.txt</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
404、500页面设置
在web.xml 中加入这些数据
<error-page>
<error-code>404</error-code>
<location>/error/404.html</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/error/500.html</location>
</error-page>