标签:方法 method erro ext not err ebs ice init
package cn.itcast.Aservlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * */ @WebServlet("/Aservlet") public class Aservlet extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public Aservlet() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.sendError(200); response.setDateHeader("expires", 1000*60*60*24); response.setIntHeader("Conten-Length", 492); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } }
package cn.itcast.Aservlet; import java.io.IOException; import javax.servlet.Servlet; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; //servlet中的方法大多数不由我们调用而是服务器,并且对象也是由服务器创建 public class Bservlet implements Servlet { ServletConfig conf; //生命周期方法,Servlet即将结束时Tomcat自动调用,只运行一次,目的释放非内存资源比如关闭IO流等; @Override public void destroy() { System.out.println("destroy"); } //获取servlet配置信息 @Override public ServletConfig getServletConfig() { return conf; } //获取servlet的信息 @Override public String getServletInfo() { return "快乐的servlet"; } //生命周期方法,出生时自动运行,tomcat调用只运行一次 @Override public void init(ServletConfig conf) throws ServletException { this.conf=conf; } //生命周期方法,tomcat调用 @Override public void service(ServletRequest arg0, ServletResponse arg1) throws ServletException, IOException { } }
标签:方法 method erro ext not err ebs ice init
原文地址:http://www.cnblogs.com/wangyinxu/p/7402307.html