Client - Controller - Service - DAO - mapper.xml
Client - Controller - Service - Mapper.java - mapper.xml
DAO(Data Access Object)?
데이터에 접근하는 트랜잭션 객체로, DB에 접근해서 데이터 조회와 같은 기능을 담당한다.
Mapper Interface?
Mybatis를 사용해서 sql을 호출하기 위한 Interface
1. Ex_SQL.xml
<mapper namespace="com.mapper.ExMapper">
<select id="selectList" parameterType="egovMap" resultType="egovMap">
select * from ExTable
</select>
</mapper>
2. ExMapper.java
@Mapper("ExMapper")
public interface ExMapper {
List<?> selectList(String ex) throws Exception;
}
3. ExService.java
public interface ExService {
List<?> selectList(EgovMap map) throws Exception;
}
4. ExServiceImpl.java
@Service("ExService")
public class ExServiceImpl implements ExService {
@Resource(name = ExMapper")
private ExMapper exMapper;
public List<?> selectList(EgovMap map) throws Exception {
return boardPageMapper.selectList(map);
}
}
5. ExController.java
@Controller
public class ExController {
@Resource(name = "ExService")
private ExService exService;
@RequestMapping(value="/ex")
public String ex(@RequestParam String param, HttpServletRequest request, HttpServletResponse response) {
List<?> exList = exService.selectList(param);
return;
}
}