0
這裏是我的春天控制器:POST方法沒有得到所謂的
@Controller
public class ReportsController {
@RequestMapping(value = "/reports.html", method = RequestMethod.GET)
public String getReportsPage(HttpServletRequest request, HttpServletResponse response, ModelMap map) {
map.addAttribute("searchCriteria", new SearchCriteria());
return "reports";
}
@RequestMapping(value = "/reports.html", method = RequestMethod.POST)
public String generateReport(@ModelAttribute SearchCriteria searchCriteria, HttpServletRequest request, HttpServletResponse response, ModelMap map) {
log.info(searchCriteria.toString());
return "reports";
}
}
,這裏是我的JSP文件形式:
<form:form modelAttribute="searchCriteria" class="form-inline">
<div class="form-group">
<label for="startDate">Start Date</label>
<form:input path="startDate" />
</div>
<div class="form-group">
<label for="endDate">End Date</label>
<form:input path="endDate" />
</div>
<button type="submit">Generate Report</button>
</form:form>
我已經嘗試添加method
和action
到form
標籤並且將它們設置爲分別post
和http://bjpeter.company.com:8080/appName/reports.html
,但POST方法不會被調用。
的GET方法被調用時,我去那個頁面,這是我想要的,但在我的控制器POST方法時,我提交表單不叫,並返回一個空白頁。
任何想法將不勝感激!