【发布时间】:2016-11-11 04:31:04
【问题描述】:
我正在向控制器发帖,这是带有动作参数值的表单
<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
.
【问题讨论】:
-
据我所知,默认请求方法是 GET,因此您必须在控制器中指定请求类型
-
那为什么告诉请求方法post不支持
-
不应该是请求方式GET不支持吗?
-
如果这是问题
-
尝试在您的表单中添加 method="GET" ,希望这会奏效。
<form action="searchT" method="GET">
标签: spring spring-mvc http-post http-status-code-405