Java Script & HTML

put, delete 메서드로 submit 하기

LichKing 2016. 12. 4. 13:04

REST 방식으로 URI를 설계할때 기존 get, post 이외에 put, delete 메서드를 추가로 사용하게된다.

그런데 form 태그의 method 속성은 get과 post밖에 지원하지 않는다.

메서드를 put으로 지정했는데 get으로 날아가길래 왜 그런가 하다가 알게된 사실이다;;


<form name="question" method="post" action="/question/{{id}}">
<input type="hidden" name="_method" value="put"/>
</form>

이런식으로 input 태그를 이용해서 put, delete 메서드를 활용할 수 있다.