在Spring MVC @RequestMapping註解中,我返回JSP頁面名稱作爲結果。這將返回HTTP狀態碼200 OK。我如何將此狀態代碼更改爲201創建的內容?Spring MVC返回自定義HTTP狀態碼(無錯誤)
@ResponseStatus不起作用。而且,HttpServletResponse將不起作用,因爲我只需要返回我的自定義JSP頁面。
@RequestMapping(method = RequestMethod.POST)
public String addPhone(@ModelAttribute("phone") Phone phoneVO) {
phoneManager.addPhone(phoneVO);
return "redirect:/phone";
}
你發佈的內容應該會返回給你301或302.你正在做一個重定向。 –
它返回HTTP 200 OK –