thymeleaf12 [thyemeleaf] get query string parameter thyemeleaf에서 url의 query string 사용미래에 이 내용을 잊었을 내가 보기 위해 기록함위 사진에서처럼 url이 http://localhost:8080/tables/detail?tableName=tb_menu 일 경우 다른 페이지 이동 시 query string parameter를 가져와서 get으로 넘기고 싶을 땐아래처럼 사용하면 된다.필드추가${param.parameter} 이 부분이다.여러개를 넘기고 싶을 땐 아래처럼 하면 된다.${param.fields[index]}test1test2test3 그러면 아래처럼 필드추가 페이지 이동 시 쿼리스트링이 전달됨을 확인 할 수 있다. Reference: https://attacomsian.com/blog/thymeleaf-get-query.. 💻 it/development 2026. 1. 11. [thymeleaf/javascript]thymeleaf값을 javascript에서 사용 미래의 내가 보기 위해 javascript에서 thymeleaf값을 사용하는 방법을 기록한다.코드로 대체한다.javascript(thymeleaf안의 script)// script에 th:inline 붙여야 함controller@GetMapping("/list") public String list(Model model) { List list = userService.selectUserList(); model.addAttribute("list", list); return "view 페이지"; }reference: https://stackoverflow.com/questions/25687816/setting-up-a-javascript-variable-from.. 💻 it/development 2025. 12. 10. [thyemeleaf] select option값 list loop 요즘에 업무가 너무 바빠서 코드로 대체함controller//코드값 조회 후 화면에 데이터 전달List tList = commonService.selectCommonDtlCodeList("T");model.addAttribute("tList", tList);html 전체 th:value는 서버로 전송할 value값이 세팅되고 th:utext는 화면에 보여질 텍스트가 세팅된다. 💻 it/development 2025. 12. 10. [thyemeleaf] get 방식 parameter값 붙이기 코드로 대체함 0}" th:each="list : ${list}"> 아래와 같은 URL이 생성된다.(empId, empSno는 서버에서 가져온 값)localhost:8080/user/view?empId=test&empSno=1(예시) 💻 it/development 2025. 12. 10. [thyemeleaf] form 검색값 유지 코드로 대체함 form태그에 th:object로 서버에서 form 데이터를 받을 Vo 입력controller에서도 UserVo로 데이터를 받도록 설정@GetMapping(value = "list")public Object testList(@ModelAttribute("userVo") UserVo userVo) { ... 생략}그 후 화면의 input과 같은 엘리먼트 태그에 th:field="*{vo에 담긴 필드명}"을 선언하면 된다. 💻 it/development 2025. 11. 24. [thymeleaf] if unless 조건 0}"> 삭제0}">데이터가 없다.※ 삽질을 좀 했는데 th:if의 조건과 th:unless의 조건은 동일하게 적어야 한다. 💻 it/development 2025. 11. 24. [thymeleaf] thymeleaf javascript로 변수 1개 이상 전달 ...//상세 팝업(2개의 매개변수를 받음) function annualViewPop(id, sno) { const width = 750; const height = 600; const left = (window.innerWidth - width) / 2; const top = (window.innerHeight - height) / 2; const popWindow = window.open("/viewPop?empId=" + id + "&annualSno=" + sno, "viewPop", "width=" + width + ", height=" + height + ", left=" + left + ", top=" + .. 💻 it/development 2025. 11. 23. [thymeleaf] 리터럴 대체 아래처럼 "| 여기에 입력하면 문자열로 인식한다. |"이렇게 안하면 문자와 표현식(${})을 + 쓰고 이스케이프('\') 쓰고 코드가 지져분해지고 가독성도 안 좋아진다."| |" 활용해서 사용하자. 💻 it/development 2025. 11. 23. [thymeleaf] 문자열 합치기 thymeleaf에서 문자열 합치기제일 깔끔한 건 ||안에 리터럴("문자열")과 표현식(${})을 넣으면 된다. 💻 it/development 2025. 11. 23. [thymeleaf] js에서 thymeleaf값 사용하기 js에서 thymeleaf에서 사용하기//th:inline="javascript" 명시해야 함 💻 it/development 2025. 11. 23. [thymeleaf] 동적 url 생성(feat. @{/url}) 사용자목록웹 애플리케이션의 Context Path를 기반으로 상대경로로 URL 생성Conext Path가 "/"일 경우 위와 같이 작성할 경우 호스트:8080/user로 url이 생성된다.보통 정적 url말고 동적 url을 많이 사용한다.※ 정적 url 작성 시 리소스 경로가 변경될 경우 다시 변경해야 한다. 💻 it/development 2025. 11. 16. [thymeleaf] Thymeleaf Layout (feat. sb-admin 2) bootstrap sb-admin 2를 이용한 Thymeleaf Layout 적용폴더 구조fragments폴더의 sidebar, config, footer 등의 공통으로 사용될 파일조각들을 default_layout.html에서 연결 후 layout을 각 html에 적용해서 사용build.gradleplugins { id 'java' id 'org.springframework.boot' version '3.3.7' id 'io.spring.dependency-management' version '1.1.7'}group = 'com.duo'version = '0.0.1-SNAPSHOT'java { toolchain { languageVersion = JavaLanguage.. 💻 it/development 2025. 11. 10. 이전 1 다음