본문 바로가기
백엔드/타임리프

타임리프 속성 값 설정

by 김어찐 2021. 9. 12.
728x90

controller

    @GetMapping("/attribute")
    public String attribute(){
        return "basic/attribute";
    }

HTML

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>속성 설정</h1>
<input type="text" name="mock" th:name="userA" />
<h1>속성 추가</h1>
- th:attrappend = <input type="text" class="text" th:attrappend="class='large'" /><br/>
- th:attrprepend = <input type="text" class="text" th:attrprepend="class='large'" /><br/>
- th:classappend = <input type="text" class="text" th:classappend="large" /><br/>
<h1>checked 처리</h1>
- checked o <input type="checkbox" name="active" th:checked="true" /><br/>
- checked x <input type="checkbox" name="active" th:checked="false" /><br/>
- checked=false <input type="checkbox" name="active" checked="false" /><br/>
</body>
</html>

크롬 화면

 

728x90

'백엔드 > 타임리프' 카테고리의 다른 글

타임리프 조건식(if, unless, switch)  (0) 2021.09.12
타임리프 반복(each)  (0) 2021.09.12
타임리프 연산  (0) 2021.09.12
타임리프 리터럴  (0) 2021.09.12
타임리프 URL 링크  (0) 2021.09.11