CONTROLLER
ViewController와 ManageController로 구분해 두었다.
페이지 접속은 ViewController를 통하며, 동적 작업은 ManageController를 통한다.
ViewController
@Controller
public class PD0010ViewController {
@Resource(name = "PD0010Service")
private PD0010Service PD0010Service;
@RequestMapping(value = "/")
public String index(Model model) throws Exception {
return "PD0010/PD0010";
}
}
ManageController
@Controller
public class PD0010ManageController {
@Resource(name = "PD0010Service")
private PD0010Service PD0010Service;
@PostMapping(value = "/PD0010/list.do")
@ResponseBody
public ModelAndView selectList(@RequestBody PD0010VO vo, Model model) throws Exception {
ModelAndView mav = new ModelAndView();
mav.setViewName("jsonView");
List<PD0010VO> listOne = PD0010Service.getListOne(vo);
mav.addObject("listOne", listOne);
return mav;
}
}
SERVICE
public interface PD0010Service {
List<PD0010VO> getList() throws Exception;
List<PD0010VO> getListOne(PD0010VO vo) throws Exception;
}
SERVICEIMPL
@Service("PD0010Service")
public class PD0010ServiceImpl implements PD0010Service{
@Resource(name="PD0010Dao")
private PD0010Dao PD0010Dao;
@Override
public List<PD0010VO> getList() throws Exception {
return PD0010Dao.selectInfoList();
}
@Override
public List<PD0010VO> getListOne(PD0010VO vo) throws Exception {
List<PD0010VO> data = PD0010Dao.selectOneList(vo);
System.out.println(data);
return data;
}
}
DAO
@Repository("PD0010Dao")
public class PD0010Dao {
private static final String MAPPER_ID = "PD0010Dao";
@Autowired
private SqlSession sqlSession;
public List<PD0010VO> selectInfoList() throws Exception {
return sqlSession.selectList(MAPPER_ID + ".selectInfoList");
}
public List<PD0010VO> selectOneList(PD0010VO vo) throws Exception {
return sqlSession.selectList(MAPPER_ID + ".selectOneList", vo);
}
}
VO
@Getter
@Setter
public class PD0010VO {
private String id;
private String pw;
private String manufacturer;
private String unit;
private String proNumber;
private String beYn;
private String useYn;
}
MAPPER
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="PD0010Dao">
<select id="selectInfoList" parameterType="com.newlecture.web.vo.PD0010VO" resultType="com.newlecture.web.vo.PD0010VO">
SELECT
*
FROM
PD0010
</select>
<select id="selectOneList" parameterType="com.newlecture.web.vo.PD0010VO" resultType="com.newlecture.web.vo.PD0010VO">
SELECT
*
FROM
PD0010
WHERE
ID = #{id}
</select>
</mapper>
MYBATIS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<setting name="cacheEnabled" value="false" />
<setting name="jdbcTypeForNull" value="NULL" />
<setting name="mapUnderscoreToCamelCase" value="true" />
</settings>
</configuration>
maven build 시, package does not exist (0) | 2023.08.07 |
---|---|
system property 기본 값, 설정 법, tomcat으로 설정 (0) | 2023.05.16 |
JUnit4 Test path 설정 (0) | 2023.03.28 |
controller @RequestBody, @RequestParam, @ModelAttribute 차이 (0) | 2022.11.28 |
Spring Controller 에서 Jsp 값 넘기기 (0) | 2022.11.14 |