Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- webserver #WAS #ServerApp
- CONTINUE
- https://www.inflearn.com/course/lecture?courseslug=%ea%b9%80%ec%98%81%ed%95%9c%ec%9d%98-%ec%8b%a4%ec%a0%84-%ec%9e%90%eb%b0%94-%ea%b8%b0%eb%b3%b8%ed%8e%b8&unitid=194690
- Forwarding
- GET방식
- JSON형식의 response
- https://www.inflearn.com/course/lecture?courseslug=%ea%b9%80%ec%98%81%ed%95%9c%ec%9d%98-%ec%8b%a4%ec%a0%84-%ec%9e%90%eb%b0%94-%ea%b8%b0%eb%b3%b8%ed%8e%b8&unitid=194711
- Spring MVC
- WAS
- sendRedirect
- 매핑 #
- 한글깨짐
- Break
- 요구사항정의서
- Dispatcher
- xml
- 김영한
- https://www.inflearn.com/course/lecture?courseslug=%ea%b9%80%ec%98%81%ed%95%9c%ec%9d%98-%ec%8b%a4%ec%a0%84-%ec%9e%90%eb%b0%94-%ea%b8%b0%eb%b3%b8%ed%8e%b8&unitid=194709&category=questiondetail&tab=community&q=1314387
- 화면정의서
- POST방식
- Request
- 톰캣
- 다형성 #부모타입 #자식타입
- while문
- 피그마
- Servlet
Archives
- Today
- Total
Step it up now
insert 흐름 이해하기 본문
NoticeDao.java
// localhost:8000/notice/noticeInsert?n_titel=제목1&n_content=내용1&n_writer=작성자1
// 크롬에 이 경로를 입력하고 엔터 치는 순간 pMap 값은
// -> pMap = {n_title=제목, n_contnet=내용, n_writer=작성자1}
public int noticeInsert(Map<String, Object> pMap) {
logger.info("noticeInsert");
int result = 0;
result = sqlSessionTemplate.insert("noticeInsert", pMap); //1 쿼리문이 성공한다면 1이 담김 /실패시 0
//sqlSessionTemplate.commit();//빼먹으면 물리적인테이블 반영안됨
return result; //0-> 1-> 1
}
📢 localhost:8000/notice/noticeInsert?n_titel=제목1&n_content=내용1&n_writer=작성자1 (GET방식)
주소 입력하는 순간, xml 파일에서 noticeInsert와 같은 id값인 noticeInsert 을 찾아 매핑됨
notice.xml
<insert id="noticeInsert" parameterType="java.util.Map">
insert into notice(n_no, n_title, n_content, n_writer)
values(seq_notice_no.nextval, #{n_title}, #{n_content}, #{n_writer})
</insert>
💡 각각의 n_no, n_title, n_content, n_writer에 값이 저장된다
이 값은 pmap에 저장된다
NoticeDao.java
result = sqlSessionTemplate.insert("noticeInsert", pMap); //1 쿼리문이 성공한다면 1이 담김 /실패시 0
return result; //0-> 1-> 1
📢 result에 결과 값이 담기고 Dao를 호출하는 Logic으로 return한다
noticeLogic.java
public int noticeInsert(Map<String, Object> pMap) {
logger.info("NoticeLogic.noticeInsert");
int result = 0;
result = noticeDao.noticeInsert(pMap); //1
return result;
📢 초기화된 result값에 Dao에서 가져온 pMap의 값이 result에 새로 담긴다
이것을 호출한 Controller로 다시 return~!
noticeController.java
public String noticeInsert(@RequestParam Map<String, Object> pMap){
logger.info(pMap.get("n_title").toString());
logger.info(pMap.get("n_content").toString());
int result = 0;
String path = "";
result = noticeLogic.noticeInsert(pMap); //Logic에서 가져온 1
if(result==1){
path = "redirect:noticeList";
} else {
path = "redirect:error.jsp";
}
return path;
//req.setAttribute("noticeInsert", result);
}
📢 result 값 0, path 값도 빈문자열이다
noticeLogic에서 가져온 result 값이 1이 맞으면 noticeList로 ~
'수업 > Spring' 카테고리의 다른 글
noticeList.jsp (0) | 2024.01.08 |
---|---|
AOP (0) | 2024.01.05 |
restcontroller필기 (1) | 2023.12.21 |
spring 1218 (0) | 2023.12.18 |
VSCode 설정 (0) | 2023.12.18 |