Reputation: 148
Before anyone tries to mark this as duplicated or mark down because of a lack of research I acknowledge this question already exists on stack overflow but the offered solutions do not solve my problem so I wanted to see if people could solve this unique problem I am experiencing.
this is my form
<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>
and this appears in my 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>
and this is my webcontroller
@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";
}
and the error message I am getting is HTTP method POST is not supported by this URL
Upvotes: 0
Views: 2067
Reputation: 1738
Do this:
@RequestMapping(value="/addQuestion", method=RequestMethod.POST)
Upvotes: 1