com.oracleclub.study.mvc.bo.EmpBO.java
package com.oracleclub.study.mvc.bo;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.oracleclub.study.mvc.dao.EmpDAO;
import com.oracleclub.study.mvc.model.Emp;
/**
* 사원관리 비즈니스로직 처리
*
* @author : oramaster
*
*/
@Service
public class EmpBO {
@Autowired
private EmpDAO empDAO;
/**
* 사원목록 조회
*
* @return
*/
public List<Emp> getEmpList() {
return empDAO.selectEmpList();
}
}
/srping/applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd"
default-autowire="byName">
<context:component-scan base-package="com.oracleclub.study">
<context:exclude-filter type="annotation"
expression="org.springframework.stereotype.Controller" />
</context:component-scan>
</beans>
com.oracleclub.study.mvc.controller.EmpListController.java
package com.oracleclub.study.mvc.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.oracleclub.study.mvc.bo.EmpBO;
/**
* 사원목록 조회
*
* @author : gurubee
*
*/
@Controller
public class EmpListController {
@Autowired
private EmpBO empBO;
@RequestMapping(value = "/emp/list")
public ModelAndView list() {
ModelAndView mv = new ModelAndView();
// 사원정보 조회 추가
mv.addObject("empList", empBO.getEmpList());
// View 지정
// mvc-dispatcher-servlet.xml 파일의 viewResolver를 사용
mv.setViewName("emp/list");
return mv;
}
}
![]() |