您好我刚开始学习Spring mvc,我使用spring mvc @annotation,我有3个servlet调度程序(appservlet,admin,student):
的web.xml
@Controller
public class AuthentificationController {
@RequestMapping(value = "verifier", method = RequestMethod.POST)
public ModelAndView redir(@ModelAttribute("per") Personne per,
HttpSession session) {
if (p1.equals(per)) {
session.setAttribute("login", per);
ModelAndView M = new ModelAndView(".admin");
return M;
}
if (p2.equals(per)) {
ModelAndView M = new ModelAndView(".student");
return M;
} else {
ModelAndView M = new ModelAndView("home");
return M;
}
}
}
在方法中进行测试后,我希望重定向到另一个servlet调度程序,无论是.admin还是.student。我该怎么办呢?
@Controller
ModelAndView
问题是people attendees events
+----+------+ +------+------+ +----+-------------------------+
| id | name | | p_id | e_id | | id | name |
+----+------+ +------+------+ +----+-------------------------+
| 1 | Bob | | 1 | 1 | | 1 | Company Christmas party |
| 2 | Anne | | 2 | 1 | | 2 | Christmas party cleanup |
| 3 | John | | 3 | 1 | | 3 | John's birthday party |
+----+------+ | 3 | 3 | +----+-------------------------+
+------+------+
返回(.jsp)但是我希望重定向另一个servlet-dispatcher !!
答案 0 :(得分:0)
你在这里:
@RequestMapping(value = "verifier", method = RequestMethod.POST)
public String redir(@ModelAttribute("per") Personne per, HttpSession session) {
if (p1.equals(per)) {
session.setAttribute("login", per);
return "redirect:.admin";
} else if (p2.equals(per)) {
return "redirect:.student"
} else {
return "home";
}
}