在任何人因缺乏研究而试图将其标记为重复或标记之前,我承认这个问题已经存在于堆栈溢出中,但提供的解决方案不能解决我的问题,所以我想看看人们是否可以解决这个独特的问题我正在经历。
这是我的表格
<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>
这是我的网络 Controller
@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)
关于java - 消息: HTTP method POST is not supported by this URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27145927/