Repository navigation
Expand file tree
/
Copy pathRequestMapping.java
More file actions
49 lines (42 loc) · 1.88 KB
/
Copy pathRequestMapping.java
File metadata and controls
49 lines (42 loc) · 1.88 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
37
38
39
40
41
42
43
44
45
46
47
48
49
package core.mvc;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import next.controller.AddAnswerController;
import next.controller.CreateUserController;
import next.controller.DeleteAnswerController;
import next.controller.HomeController;
import next.controller.ListUserController;
import next.controller.LoginController;
import next.controller.LogoutController;
import next.controller.ProfileController;
import next.controller.ShowController;
import next.controller.UpdateFormUserController;
import next.controller.UpdateUserController;
public class RequestMapping {
private static final Logger logger = LoggerFactory.getLogger(DispatcherServlet.class);
private Map<String, Controller> mappings = new HashMap<>();
void initMapping() {
mappings.put("/", new HomeController());
mappings.put("/users/form", new ForwardController("/user/form.jsp"));
mappings.put("/users/loginForm", new ForwardController("/user/login.jsp"));
mappings.put("/users", new ListUserController());
mappings.put("/users/login", new LoginController());
mappings.put("/users/profile", new ProfileController());
mappings.put("/users/logout", new LogoutController());
mappings.put("/users/create", new CreateUserController());
mappings.put("/users/updateForm", new UpdateFormUserController());
mappings.put("/users/update", new UpdateUserController());
mappings.put("/qna/show", new ShowController());
mappings.put("/qna/addAnswer", new AddAnswerController());
mappings.put("/qna/deleteAnswer", new DeleteAnswerController());
logger.info("Initialized Request Mapping!");
}
public Controller findController(String url) {
return mappings.get(url);
}
void put(String url, Controller controller) {
mappings.put(url, controller);
}
}