파게로그
[Spring MVC] 데이터 서비스 클래스 본문
public class NoticeService {
private String url = "jdbc:oracle:thin:@localhost:1521/xepdb1";
private String uid = "berry";
private String pwd = "qwer123";
private String driver = "oracle.jdbc.driver.OracleDriver";
// ...
}
public class ListController implements Controller {
private NoticeService noticeService;
public void setNoticeService(NoticeService noticeService) {
this.noticeService = noticeService;
}
@Override
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) {
ModelAndView mv = new ModelAndView("notice.list");
List<Notice> list = noticeService.getList(1, "TITLE", "");
mv.addObject("list", list);
return mv;
}
}
dispatcher-servlet.xml
<bean id="/index" class="NoticeController" >
<bean class="com.ddoongi.web.service.NoticeService" />
list.jsp
<!-- tag library -->
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!-- items: mv that was returned -->
<c:forEach var="n" items="${list}">
<tr>
<td>${n.id}</td>
<!-- ... -->
</tr>
</c:forEach>
'콤퓨타 왕기초 > Spring' 카테고리의 다른 글
[JDBC] JDBC 연결 (0) | 2021.05.01 |
---|---|
[JDBC] JDBC (0) | 2021.05.01 |
[Spring MVC] Tiles를 통한 페이지 모듈 분리(Retired Framework) (0) | 2021.04.29 |
[Spring MVC] 정적인 리소스 서비스하기 (0) | 2021.04.26 |
[Spring MVC] ViewResolver (0) | 2021.04.26 |
Comments