[SpringBoot] GET, POST 이외의 HTTP 메서드 사용하기 위한 설정

2023. 5. 5. 19:53spring

 

application.yml 설정


spring:
  mvc:
    hiddenmethod:
      filter:
        enabled: true

 

HTML 에서 delete 메서드 사용하여 form전송 예시

<a class="btn btn-sm btn-outline"
   href="javascript:"
   onclick="if ( confirm('정말로 취소하시겠습니까?') ) $(this).next().submit();">
    <i class="fa-solid fa-user-slash"></i>
    &nbsp;
    취소
</a>
<form hidden th:action="@{|/usr/likeablePerson/${likeablePerson.id}|}" method="POST">
    <input type="hidden" name="_method" value="delete">
</form>