您好,我在這個控制器有一個有線行爲。我有兩種方法獲取準備的資料在html表單和POST顯示獲得德提出:@RequestMapping(method = RequestMethod.POST)提交後得到HTTP狀態405 - 請求方法'POST'
控制器:
@Controller
public class NotificationController {
final String JSP_NOTIFICATION_01="pages/sendPush/createNotification";
final String JSP_NOTIFICATION_02="pages/sendPush/createNotificationStep2";
@RequestMapping(value ="/admin/notification/newNotification",method = RequestMethod.GET)
public String newNotification(Map<String, Object> model, HttpServletRequest request) {
//prepare info to fill html form
request.getSession().setAttribute("notificacion", notification);
return JSP_NOTIFICATION_01;
}
@RequestMapping(value ="/admin/notification/sendNotification", method = RequestMethod.POST)
public String saveNotification(@ModelAttribute("notForm") SendNotificationModel notForm,
Map<String, Object> model,HttpServletRequest request) {
//Get all information from HTML form
System.out.println("llego.."+resultado);
model.put("resultado", resultado);
return JSP_NOTIFICATION_02;
}
}
JSP
<form:form action="${pageContext.request.contextPath}/admin/notification/sendNotification" method="post" commandName="notForm">
<form:hidden path="clientName" />
<form:hidden path="clientCode" />
</tr>
<tr>
<td>topics:</td>
<td><form:select path="topics" items="${topicList}" /></td>
</tr>
<tr>
<td>users:</td>
<td><form:select multiple="true" path="users" items="${userList}" /></td>
</tr>
<tr>
<td>Tipo de despliege :</td>
<td><form:select path="tipoNotificacion" items="${tipoNotificacionList}" /></td>
</tr>
</table>
<tr>
<td colspan="2" align="center"><input type="submit" value="Enviar" /></td>
</tr>
</table>
</form:form>
提交POST方法後一如既往接到請求,但回覆彈簧後拋出405錯誤:
HTTP Status 405 - Request method 'POST' not supported
type Status report
message Request method 'POST' not supported
description The specified HTTP method is not allowed for the requested resource.
我使用Spring 4.1.3和tomcat8
謝謝!!!
確保你提供確切的參數,您的帖子方法 – koutuk
@koutuk將有什麼不同?爲什麼錯誤的參數會導致405? –