[英]Not able to redirect to another method of controller in Spring MVC using path variable
我有一個控制器類,其中有兩種方法。 我正在從 jsp 提交表單,然后控制進入第一種方法,從第一種方法我使用路徑變量重定向到第二種方法,但它不起作用。
下面是我的代碼:
@Controller
public class UserController {
@RequestMapping(value = "saveUserDetails", method = RequestMethod.POST)
public String saveUser(ModelMap map, HttpSession session,HttpServletRequest request) {
String strId= request.getParameter("userId");;
return "redirect:userView/" + strId;
}
@RequestMapping(value="userView/{id}", method = RequestMethod.GET)
public String displayUser(@PathVariable String id, Model model) {
System.out.println("in method2");
return "showUser";
}
}
當用戶從jsp提交表單然后控制進入saveUser()方法時,我正在重定向到另一個方法displayUser(),但由於某種原因它不起作用。 有人可以幫我嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.