본문 바로가기

Thymeleaf

[Thymeleaf] 배열 데이터 each 없이 한번에 표현 public enum AttendanceReportReason { NONE("해당없음", "0", new AttendanceStudentType[]{AttendanceStudentType.ATTEND, AttendanceStudentType.ABSENT}), ` ` ` OMISSION("누락", "1", new AttendanceStudentType[]{AttendanceStudentType.ATTEND_CORRECTION, AttendanceStudentType.LEAVE_CORRECTION}), private String text; private String value; private AttendanceStudentType[] reportType; } view에서 AttendanceReportReas..
[Thymeleaf] 커스텀 데이터 속성 사용법 동적으로 그려진 html 각 요소들을, 추후 사용자의 동작에 맞춰 컨트롤하고 싶을때가 있습니다. 이런 경우 각 태그에 attribute를 부여해놓으면 쉽게 컨트롤 할 수 있습니다. el_id에 element.getId() 값을 세팅하는 코드입니다. 태그 안에서 여러개 속성을 동시에 부여할 수도 있습니다. $("li").data("el_id"); jQuery를 활용하여 설정한 attribute에 쉽게 접근할 수 있습니다. 참고 1 : https://stackoverflow.com/questions/24411826/using-data-attribute-with-thymeleaf
[Thymeleaf] 스프링 모델 값을 자바스크립트에서 사용하기 컨트롤러에서 스프링 모델에 담은 값을 자바스크립트에서 사용하고 싶을때 필요한 코드입니다. ${session.user.name}에 접근하여 username을 세팅해줍니다. Sebastian은 페이지가 정적으로 로딩될때 사용될 값입니다. 기본값의 기능을 한다고 보시면 됩니다. 참조 : https://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html#script-inlining-javascript-and-dart