package servlet; import java.io.IOException;
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 GetInitParameterServlet
*/
@WebServlet(//此版块是从其他博主的文章学习过来的,侵删
//Servlet的访问URL
value="/servlet/GetInitParameterServlet",
//Servlet的访问URL,可以使用数组的方式配置多个访问路径
urlPatterns={"/servlet/GetInitParameterServlet"},//此方法和value的作用一样
//Servlet的初始化参数
initParams={
@WebInitParam(paramName="zsms",paramValue="醉生梦死")//在服务器初始化的时候会打印,因为调用Init方法
},
name="GetInitParameterServlet",//不填的话默认是类的路径
description="处理用户登录的Servlet"
)
public class GetInitParameterServlet extends HttpServlet {
private static final long serialVersionUID = 1L; /**
* @see HttpServlet#HttpServlet()
*/
public GetInitParameterServlet() {
super();
// TODO Auto-generated constructor stub
} /**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.getWriter().append("Served at: ").append(request.getContextPath());
} /**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
} }