|
|
|
@ -19,28 +19,41 @@ public class GetAdminByUserName extends HttpServlet {
|
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @see HttpServlet#HttpServlet()
|
|
|
|
|
* HttpServlet的构造函数。
|
|
|
|
|
*/
|
|
|
|
|
public GetAdminByUserName() {
|
|
|
|
|
super();
|
|
|
|
|
// TODO Auto-generated constructor stub
|
|
|
|
|
// 构造函数中的代码,通常不需要自定义操作,因为父类已经处理
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
|
|
|
|
* 处理GET请求的方法。
|
|
|
|
|
* 当客户端发送GET请求时,这个方法会被调用。
|
|
|
|
|
* @param request HttpServletRequest对象,包含客户端请求信息。
|
|
|
|
|
* @param response HttpServletResponse对象,用于发送响应到客户端。
|
|
|
|
|
* @throws ServletException 可能抛出的Servlet异常。
|
|
|
|
|
* @throws IOException 可能抛出的IO异常。
|
|
|
|
|
*/
|
|
|
|
|
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
|
|
|
|
// 从session中获取名为"admin"的属性,该属性通常在管理员登录时被设置
|
|
|
|
|
Admin admin = (Admin) request.getSession().getAttribute("admin");
|
|
|
|
|
// 将管理员对象设置为request的属性,以便在JSP页面中可以访问
|
|
|
|
|
request.setAttribute("admin", admin);
|
|
|
|
|
// 使用RequestDispatcher将请求转发到指定的JSP页面
|
|
|
|
|
// "pages/admin/right/getAdmin.jsp"是JSP文件的路径
|
|
|
|
|
request.getRequestDispatcher("pages/admin/right/getAdmin.jsp").forward(request, response);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
|
|
|
|
* 处理POST请求的方法。
|
|
|
|
|
* 当客户端发送POST请求时,这个方法会被调用。
|
|
|
|
|
* @param request HttpServletRequest对象,包含客户端请求信息。
|
|
|
|
|
* @param response HttpServletResponse对象,用于发送响应到客户端。
|
|
|
|
|
* @throws ServletException 可能抛出的Servlet异常。
|
|
|
|
|
* @throws IOException 可能抛出的IO异常。
|
|
|
|
|
*/
|
|
|
|
|
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
doGet(request, response);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|