@GetMapping("/attribute")
public String attribute() {
return "basic/attribute";
}
th
는 무시되기때문에 mock
으로 적용된다.<body>
<h1>속성 설정</h1>
<input type="text" name="mock" th:name="userA" />
</body>
th:attrappend = "속성이름=' 추가할 속성'"
뒤에 추가th:attrpreappend = "속성이름='추가할 속성 '"
앞에 추가attrappend
, attrprepend
의 경우에 기존 속성에 띄어쓰기 없이 앞뒤로 추가되기 때문에, ''
안에 띄어쓰기를 넣어 줘야한다.th:classappend="추가할 속성"
th:classappend
를 사용하면 띄어쓰기 없이 뒤에 추가할 수 있다.<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/>
먼저 예시를 들어가기 앞써, HTML에서 CheckBox의 체크상태는 checked 속성의 유무로 변경할 수 있는 것을 확인했다.
th:checked="true"
면 체크박스가 체크된 상태로th:checked="false"
면 체크박스가 언체크된 상태로 출력된다.<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 /><br/>