JSP+Spring Boot(28)
-
상품 등록 폼 만들기(resources 파일)(insert)
Mapper.xml mapper로 감쌀 SQL문은 mapper 안에 모두 작성하기 INSERT INTO goods (goods_id, goods_name, goods_price, goods_quantity) VALUES(goods_seq.NEXTVAL, #{goodsName}, #{goodsPrice}, #{goodsQuantity}) ---------------------------------------------------------------------------------------------------------- index 상품 등록하기 *는 th:object 값을 가져온다는 뜻 --> 상품명 : ..
2024.06.17 -
상품등록 폼 만들기(Java 파일)(insert)
Cotrollerpackage com.example.demo.controller;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.ui.Model;import org.springframework.web.bind.annotation.GetMapping;import org.springframework.web.bind.annotation.PostMapping;import com.example.demo.dto.Goods;import com.example.demo.service.GoodsService;@Controlle..
2024.06.17 -
Thymeleaf(inline, classappend), sequence
th:inline = "javascript" - script 태그에 작성하는 속성- 타임리프 문법으로 출력된 내용/값을 JS에 알맞는 타입으로 변환 @GetMapping("ex5")public String ex5(Model model) { //message 값으로 전달할 값 작성하기 model.addAttribute("message", "타임리프 + JS 사용 예제");} th:classappend - 요소에 class 속성 값을 동적으로 추가th(타임리프)에서 제공하는 class(스타일태그) append(추가)초록색 색상 태그 실행 중class랑 classappend 같이 쓰기초록 글씨에 밑줄 치기 안전 탐색 연산자 : ${객체?.필드} - 객체가 null인지 판단 후 null이..
2024.06.14 -
Thymeleaf(switch, case)
변수 값에 따라 알맞은 case 진행. AAAAAAAA BBBBBBBB CCCCCCCC ZZZZZZZZ th:case="*" : 작성한 경우의 값 의외 모두 선택을 한다는 의미. default 대신 사용 만약 Controller에서 num 값으로 가져오는 값이 없다면 default 값인 th:case="*"에작성된 내용이 보여짐 ** 삼항 연산자- 타임 리프 속성(th:)에 삼항 연산자(조건식 ? true일 때 값 : false일 때 값) 작성 가능 삼항 연산자
2024.06.14 -
Thymeleaf (if, unless)
th:if=${조건식} - 조건식이 true인 경우에만 해당 속성이 작성된 요소를 화면에 출력 ex) th:if${만약 관리자가 접속했다면} = 상품 수정하기를 보여주겠다th:unless=${조건식} - 조건식이 false인 경우에만 해당 속성이 작성된 요소를 화면에 출력 ex) th:unless=${비밀번호가 일치하지 않는다면} = 비밀번호 찾기 버튼 보여줌 값이 없을 경우 --> std 값 없음 값이 있을 경우 --> std 값 있음 값 없음 --> mem값 없음 mem값 있음 값이 없을 경우 --> std 값 없음 값이 있을 경우 --..
2024.06.14 -
Thymeleaf(parameter, utext)
요청 위임된 request에 존재하는 파라미터 출력하기 ${param.key} - request에 존재하는 parameter(매개변수) 값 얻어와 출력타임리프 예제 2이름 : 나이 : 색상 : Red : Blue : Green : 제출하기 제출된 이름 제출된 나이 체크된 색상 th:text / th:utextExampleController 에 작성한 테스트 중 × 이 innerHTML임th:text = "속성값" - 해당 태그에 "속성값"을 내용으로 출력 - 단, html 태그, 특수문자 해석 불가능(innerHTML)th:utext = "속성값"- 해당 태그에 "속성값"을 내용으로 출력- 단, html..
2024.06.14