最近通过springboot做前端交互时,报了这个错找了很久 但是很多的代码问题都会导致 ‘POST‘ not supported ,也是找了很久 最后发现是细节问题。。。
前端:
<form method="post" th:action="@{/fruit/updateFruitInfo}" th:object="${fruit}" enctype="multipart/form-data">
<input type="hidden" th:value="*{id}" th:field="*{id}" name="id"><br/>
商品名称:<input type="text" th:field="*{name}" name="name"><br/>
价 格:<input type="text" th:field="*{price}" name="price"><br/>
时 间:<input type="date" th:field="*{date}" name="date"><br/>
是否热门:
<span th:if="*{is_hot==1}">
<input type="radio" name="is_hot" th:field="*{is_hot}" th:value="1" th:checked="true">是
<input type="radio" name="is_hot" th:field="*{is_hot}" th:value="0">否
</span>
<span th:if="*{is_hot==0}">
<input type="radio" name="is_hot" th:field="*{is_hot}" th:value="1">是
<input type="radio" name="is_hot" th:field="*{is_hot}" th:value="0" th:checked="true">否
</span>
<br/>
图片描叙:<input type="file" name="fImg">
<br/>
<input type="submit" th:value="确认修改">
</form>
开始以为是请求本身的问题,但是f11中请求都是没有问题的,最后发现如下:
请求接收是没有问题的,但是在完成修改之后跳转到查询中去,查询只接收get请求,而这里却用了
forward:/fruit/findAllFruit 转发来跳转 ,改成重定向之后正常