forked from slipp/jwp-basic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShowController.java
More file actions
23 lines (19 loc) · 843 Bytes
/
ShowController.java
File metadata and controls
23 lines (19 loc) · 843 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package next.controller.qna;
import core.mvc.Controller;
import core.mvc.modelandview.ModelAndView;
import next.dao.AnswerDao;
import next.dao.QuestionDao;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ShowController implements Controller {
@Override
public ModelAndView execute(HttpServletRequest req, HttpServletResponse resp) throws Exception {
long questionId = Long.parseLong(req.getParameter("questionId"));
QuestionDao questionDao = new QuestionDao();
AnswerDao answerDao = new AnswerDao();
return ModelAndView.builder()
.addAttribute("question", questionDao.findById(questionId))
.addAttribute("answers", answerDao.findAllByQuestionId(questionId))
.jspView("/qna/show.jsp");
}
}