Serverlet
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Serverlet相关的知识,希望对你有一定的参考价值。
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
以上是关于Serverlet的主要内容,如果未能解决你的问题,请参考以下文章