Spring boot - Thymeleaf 유용한 팁
2020. 3. 19. 15:52ㆍspring
1. application.properties 값 조회
<span th:text="${@environment.getProperty('app.title')}"></span>
2. message 조회
<span th:text="#{msg.example.title}"></span>
3. 세션 정보 조회
<span th:text="${session['userId']}"></span>
<span th:text="${session.userId}"></span>
4. Parameter 정보 조회
<span th:text="${param.authType}"></span>
<span th:text="${#httpServletRequest.getParameter('authType')}"></span>
5. PathVariable 가져오기
<span th:text="__${userId}__"></span>
* Spring 컨트롤러에 Request Mapping에 선언되어 있고 @PathVariable이 있어야만 정보를 가져올 수 있다.
6. 속성 설정
<input type="hidden" th:value="${question.id}" th:attr="name='quizID'" />
7. context path
var contextpath = '[[@{/}]]';
<img scr="@{/}/test.img">
출처 : https://stackoverflow.com/questions/25808433/hidden-field-value-blank-thymeleaf