//这是第二种开发servlet的方法(继承GernericServlet) package com.tsinghua; import javax.servlet.GenericServlet; import javax.servlet.*; import java.io.*; public class HelloGen extends GenericServlet{ //重写service方法即可 public void service(ServletRequest req, ServletResponse res) { //返回Hello,world!gerneric try{ PrintWriter pw = res.getWriter(); pw.println("Hello,world!gerneric"); } catch(Exception ex) { ex.printStackTrace(); } } }
时间: 2024-11-17 22:57:11