我使用@PathVariable註解提供一個ID到我的控制器。當我這樣做時,它會找到映射並在控制器方法內運行代碼,但是在加載JSP時無法找到它,並在下面顯示錯誤。Spring MVC的 - 使用@PathVariable沒有找到JSP
HTTP ERROR 404
Problem accessing /Timesheets/viewtimesheet/WEB-INF/pages/viewtimesheet.jsp. Reason:
Not Found
在日誌中我得到以下錯誤:
SEVERE: PWC6117: File "C:\dev\Projects\DominoTimesheets\WebContent\viewtimesheet\WEB-INF\pages\viewtimesheets.jsp" not found
如果我拿出@PathVariable那麼它運行良好,並加載按預期的頁面(但我需要有timesheetId
針對數據庫運行)。上面的路徑在導致問題的WEB-INF之前有viewtimesheet
。它似乎不喜歡/viewtimesheet/{timesheetID}
的映射有人可以對此有所瞭解嗎?
@RequestMapping(value="/viewtimesheet/{timesheetID}", method = RequestMethod.GET)
public String viewTimesheet(@PathVariable int timesheetID, ModelMap model,
final RedirectAttributes redirectAttributes, HttpSession session) {
Timesheets timesheetResult = timesheetsService.getTimesheet(timesheetID);
model.addAttribute("mondayDate", timesheetResult.getDate_WC());
model.addAttribute("viewTimesheetModel", timesheetResult);
return "viewtimesheets";
}