gpt4 book ai didi

java - @RequestMapping( method = RequestMethod.POST) 提交后获得 HTTP 状态 405 - 请求方法 'POST'

转载 作者:行者123 更新时间:2023-11-29 04:37:29 26 4
gpt4 key购买 nike

您好,我在这个 Controller 中有一个有线行为。我有两种方法 Get 准备信息以 html 形式显示和 POST 获取提交:

Controller :

@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 方法后一如既往地接收请求,但返回后 spring 抛出 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

谢谢!!!

最佳答案

从 Controller 中删除@RequestMapping(value ="/admin/notification/sendNotification")

关于java - @RequestMapping( method = RequestMethod.POST) 提交后获得 HTTP 状态 405 - 请求方法 'POST',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40713452/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com