Literal substitutions 방식으로 쓰면 편하다.
<input id = "a1">
<input id = "a2">
<input id = "a3">
<input id = "a4">
<input id = "a5">
id값이 특정문자 + index로 출력하고 싶을때 머리가 아픈적이 있었다.
이럴때는 Literal substitutions방식으로 간편하게 쓰면 된다.
<th:block th:each="num : ${#numbers.sequence(1,5)}">
<input id = "|a+${num}|"/>
</th:block>
사실 가장 진가를 발회하는건 URL부분이라고 생각한다.
<a href="/todolist/2022-09-07/3/edit?status1=100">
<a href="/todolist/2022-09-07/4/edit?status2=100">
<a href="/todolist/2022-09-07/5/edit?status3=100">
<a href="/todolist/2022-09-07/6/edit?status4=100">
input같은 경우는 사실 "${'a'+num}으로 해도된다.
하지만 url의 경우는 사정이 다르다. url에는 엔티티의 id를 넣을 수도 있고 각종 값을 객체로 부터 뽑아서 넣어야할 수 도 있기 때문에 Literal substitutions방식을 쓰지 않고는 나로서는 구현이 불가능 했다.
<a th:href="|/todolist/${date}/${todoListItem.id}/edit?status${i.count}=100|">
Literal substitutions방식을 사용하면 html에서 value,id,oninput이든 뭐든 자유롭고 편하게 사용할 수 있다.
oninput="Output5.value = success5.value"
th:oninput="|Output${i.count}.value = success${i.count}.value|"