package sn.dolp; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * Servlet implementation class MyServlet */ @WebServlet("/MyServlet") public class MyServlet extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public MyServlet() { super(); // TODO Auto-generated constructor stub } /** * 处理get请求 * req:用户获得客户端(浏览器)的信息 * res:用于向客户端(浏览器)返回信息 */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { PrintWriter pWriter = response.getWriter(); pWriter.println("Hello Servlet"); } catch (Exception e) { // TODO: handle exception } } /** * 处理post请求 * req:用户获得客户端(浏览器)的信息 * res:用于向客户端(浏览器)返回信息 */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub } }
时间: 2024-10-13 22:36:55