Reputation: 2329
I am making a post to the controller and this is the form with the action parameter value
<div class="form-group">
<form action="searchT">
<label class=" control-label col-sm-2">No</label>
<div class="col-sm-4"> <input class="form-control" type='text' name='searchName' id='searchName'/> </div>
<div class="col-sm-4"><input class="btn btn-success" type='submit' value='Validate'/></div>
</form>
</div>
this is the controller code that does the fetching of values from the database when a button is clicked
@RequestMapping("searchT")
public ModelAndView searchTOE(@RequestParam("searchName") String searchName) {
logger.info("Searching the T: "+searchName);
List<TOE> tinList = TOEService.getAllTins(searchName);
return new ModelAndView("serviceDescription", "tList", tList);
}
when I click on the submit I get this error
org.springframework.web.servlet.PageNotFound - Request method 'POST' not supported
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
.
Upvotes: 0
Views: 1331
Reputation: 4239
@RequestMapping("searchT")
Default method type is GET
. You should mention the method type as POST
in RequestMapping
.
Upvotes: 1