标签:
1.web.xml配置。
2.Serverlet源码
service函数是对客户端请求的响应代码。
package com.zkzk945.Serverlet; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class Serverlet extends HttpServlet { @Override protected void service(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException { // TODO Auto-generated method stub System.out.println("service"); // super.service(arg0, arg1); // System.out.println("hello world"); PrintWriter pw = arg1.getWriter(); pw.println("hello world"); pw.close(); } @Override public void destroy() { // TODO Auto-generated method stub System.out.println("destroy"); super.destroy(); } @Override public void init() throws ServletException { // TODO Auto-generated method stub System.out.println("init no params"); super.init(); } @Override public void init(ServletConfig config) throws ServletException { // TODO Auto-generated method stub System.out.println("init with params"); super.init(config); } }
3.源码
https://git.oschina.net/zkzk945/JavaEE.git
标签:
原文地址:http://www.cnblogs.com/zkzk945/p/5225742.html