forked from Realhedin/topjava02
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserServlet.java
More file actions
36 lines (31 loc) · 1.34 KB
/
UserServlet.java
File metadata and controls
36 lines (31 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package ru.javawebinar.topjava.web;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import ru.javawebinar.topjava.LoggerWrapper;
import ru.javawebinar.topjava.service.UserService;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* User: gkislin
* Date: 19.08.2014
*/
public class UserServlet extends HttpServlet {
private static final LoggerWrapper LOG = LoggerWrapper.get(UserServlet.class);
private WebApplicationContext wac;
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
LOG.debug("redirect to userList");
UserService userService = wac.getBean(UserService.class);
request.setAttribute("userList", userService.getAll());
request.getRequestDispatcher("/userList.jsp").forward(request, response);
// response.sendRedirect("userList.jsp");
}
}