본문 바로가기

Server/Spring

[우당탕탕 개발일지] HTML : href, delete method

반응형
SMALL

Thymeleaf의 href

html의 href를 통해서 "voucher/{voucherId}" url로 매핑시키고 싶었다. 그러기 위해선 th:href="@{..}" 형식으로 매핑시켜야 하고, voucherId 값을 가져오기 위해서는 "*{voucherId}" 형식이 필요했는데, 그래서 th:href="@{voucher/*{voucherId}}"로 써냈더니 무슨 이상한 ... voucher/*alkdjalkdfj 과 같이 *이 붙어서 나오는 것 ㅠㅠㅠ 딱!! voucherId 값만 대입하고 싶어서 찾아봤다!

th:href="@{${'/voucher/'+voucher.voucherId}}"

형식으로 해결했다 :D 값을 대입하고 싶으면 "@{${'[문자열]'+[값]}}" 형식으로 쓰자 ,,, 끄적,,,

 

Reference:

https://seollica.tistory.com/119

 

 

HTML에서 DELETE Method 사용하기

html에서 url 매핑을 시키다가 html에서는 delete method를 지원하지 않는다는 것을 깨달았다. ㅇㅁㅇ !! 그래서 폭풍 구글,,링,,

 

application.yaml (또는 application.properties) 파일에

spring.mvc.hiddenmethod.filter.enabled=true

을 추가하자. 그리고?

<form th:action="@{/voucher-delete}" th:method="delete" >
    <button type="submit" class="btn btn-primary">바우처 전체 삭제</button>
</form>

form 태그를 이용해서 delete method를 마구마구 써주자. ㅎㅁㅎ

 

Reference:

https://jaimemin.tistory.com/2098

 

 

 

반응형
LIST