我正在向控制器发帖,这是带有动作参数值
的表格<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>
这是在单击按钮时从数据库中获取值的控制器代码
@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);
}
当我点击提交时,我收到此错误
org.springframework.web.servlet.PageNotFound - 请求方法'POST'没有 支持的
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
答案 0 :(得分:1)
@RequestMapping("searchT")
默认方法类型为GET
。您应该在POST
中将方法类型称为RequestMapping
。