|
| 1 | +package com.xinan.servlet; |
| 2 | + |
| 3 | +import java.io.IOException; |
| 4 | +import javax.servlet.ServletException; |
| 5 | +import javax.servlet.annotation.WebServlet; |
| 6 | +import javax.servlet.http.HttpServlet; |
| 7 | +import javax.servlet.http.HttpServletRequest; |
| 8 | +import javax.servlet.http.HttpServletResponse; |
| 9 | + |
| 10 | +/** |
| 11 | + * Servlet implementation class HelloServlet |
| 12 | + */ |
| 13 | +@WebServlet("/HelloServlet") |
| 14 | +public class HelloServlet extends HttpServlet { |
| 15 | + private static final long serialVersionUID = 1L; |
| 16 | + |
| 17 | + /** |
| 18 | + * @see HttpServlet#HttpServlet() |
| 19 | + */ |
| 20 | + public HelloServlet() { |
| 21 | + super(); |
| 22 | + // TODO Auto-generated constructor stub |
| 23 | + } |
| 24 | + |
| 25 | + /** |
| 26 | + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse |
| 27 | + * response) |
| 28 | + */ |
| 29 | + protected void doGet(HttpServletRequest request, HttpServletResponse response) |
| 30 | + throws ServletException, IOException { |
| 31 | + // TODO Auto-generated method stub |
| 32 | + // response.getWriter().append("Served at: |
| 33 | + // ").append(request.getContextPath()); |
| 34 | + System.out.println("get请求将执行"); |
| 35 | + } |
| 36 | + |
| 37 | + /** |
| 38 | + * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse |
| 39 | + * response) |
| 40 | + */ |
| 41 | + protected void doPost(HttpServletRequest request, HttpServletResponse response) |
| 42 | + throws ServletException, IOException { |
| 43 | + // TODO Auto-generated method stub |
| 44 | + doGet(request, response); |
| 45 | + System.out.println("post请求被执行"); |
| 46 | + } |
| 47 | + |
| 48 | +} |
0 commit comments