[英]message: HTTP method POST is not supported by this URL
在任何人由于缺乏研究试图将其标记为重复或标记之前,我承认这个问题已经在堆栈溢出中存在,但是提供的解决方案不能解决我的问题,因此我想看看人们是否可以解决我遇到的这个独特问题。
这是我的表格
<form:form method="POST" action="addQuestion" >
<input type="text" name="questionId" />Enter Id<br>
<input type="text" name="theQuestion" />Enter Q <br>
<input type="text" name="category" />Enter Category<br>
<input type="text" name="correctAnswer" />Enter correct answer<br>
<input type="submit" value="Next" >
</form:form>
这出现在我的web.xml中
<servlet>
<servlet-name>addQ</servlet-name>
<servlet-class>main.WebController</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>addQ</servlet-name>
<url-pattern>/addQuestion</url-pattern>
</servlet-mapping>
这是我的网络控制器
@RequestMapping("/addQuestion")
public String addQuestion(ModelMap model, @RequestParam(value="question", required = true) String theQuestion , @RequestParam(value="questionId", required = true) Integer questionId, @RequestParam(value="category", required = true) String category, @RequestParam(value="correctAnswer", required = true) String correctAnswer) throws SQLException{
ViewController viewController = new ViewController();
viewController.createQuestion(questionId, theQuestion, category, correctAnswer);
model.addAttribute("message", "Hello hope this flipping works");
return "addQuestion";
}
并且我收到的错误消息是此URL不支持HTTP方法POST
做这个:
@RequestMapping(value="/addQuestion", method=RequestMethod.POST)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.