servlet中load-on-startup的用法
package com.cdsxt.action;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class TestLoad extends HttpServlet{
//<load-on-startup> 在web.xml中配置相关信息
//<load-on-startup> 里面 填写 负数 或0 由容器随机加载
//<load-on-startup> 里面写 大于等于0 越小 越优先 加载
//<load-on-startup> 里面写相同的数字 由web容器决定顺序
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
System.out.println("TestLoad.doGet()");
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
System.out.println("TestLoad.doPost()");
}
@Override
public void service(ServletRequest req, ServletResponse res)
throws ServletException, IOException {
System.out.println("TestLoad.service()");
super.service(req, res);
}
@Override
public void destroy() {
System.out.println("TestLoad.destroy()");
}
@Override
public void init() throws ServletException {
System.out.println("TestLoad.init()00000000");
}
}