本文主要是介绍【Servlet学习】继承HttpServlet简单示例,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
package com.sprying;import java.io.IOException;import java.io.PrintWriter;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;/***第三种方法开发servlet*通过继承HttpServlet,*/public class HttpExample extends HttpServlet{/*** */private static final long serialVersionUID = 1L;public void doGet(HttpServletRequest req,HttpServletResponse res){this.doPost(req,res);}public void doPost(HttpServletRequest req,HttpServletResponse res){try{PrintWriter pw=res.getWriter();pw.print("HelloWorld,extends of HttpServlet");}catch(IOException e){e.printStackTrace();}}}
这篇关于【Servlet学习】继承HttpServlet简单示例的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!