// // Source code recreated from a .class file by IntelliJ IDEA // (powered by FernFlower decompiler) // package Servlet; import Service.impl.UserServiceImpl; import domain.User; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.List; @WebServlet({"/userListServlet"}) public class userListServlet extends HttpServlet { public userListServlet() { } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); UserServiceImpl service = new UserServiceImpl(); List<User> users = service.findAll(); request.setAttribute("users", users); request.getRequestDispatcher("/list.jsp").forward(request, response); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.doPost(request, response); } }
时间: 2024-03-30 20:33:23 浏览: 137
ResultDTO返回封装工具类
这是一个 Servlet,用于处理用户请求并返回用户列表。该 Servlet 使用了 UserServiceImpl 类的实现来获取用户列表,并将其存储在 request 对象中,最后将请求转发到 list.jsp 页面。其中,doPost() 方法处理 POST 请求,doGet() 方法处理 GET 请求。该 Servlet 的 URL 映射为 "/userListServlet"。
阅读全文