spring mvc怎么在同一个controller里面进行方法相互跳转
1个回答
展开全部
/**
* 添加职称
* @param teacherTitle
* @return
*/
@RequestMapping(value="/addTitle",method={RequestMethod.POST,RequestMethod.GET})
public String addTitle(TeacherTitle teacherTitle,Model model){
try {
titleService.add(teacherTitle);
System.out.println("1111");
<span style="color:#ff0000;">return REDIRECT + "listTitles";</span>
} catch (Exception e) {
e.printStackTrace();
return "error";
}
}
/**
* 列出所有职称
* @param model
* @return
*/
@RequestMapping(value="/listTitles")
public String listTitles(Model model){
try {
List<TeacherTitle> titles = titleService.findAll(TeacherTitle.class);
if (titles!=null){
model.addAttribute("titles", titles);
return PARENTPATH + "title";
}
return "error";
} catch (Exception e) {
e.printStackTrace();
return "error";
}
}
* 添加职称
* @param teacherTitle
* @return
*/
@RequestMapping(value="/addTitle",method={RequestMethod.POST,RequestMethod.GET})
public String addTitle(TeacherTitle teacherTitle,Model model){
try {
titleService.add(teacherTitle);
System.out.println("1111");
<span style="color:#ff0000;">return REDIRECT + "listTitles";</span>
} catch (Exception e) {
e.printStackTrace();
return "error";
}
}
/**
* 列出所有职称
* @param model
* @return
*/
@RequestMapping(value="/listTitles")
public String listTitles(Model model){
try {
List<TeacherTitle> titles = titleService.findAll(TeacherTitle.class);
if (titles!=null){
model.addAttribute("titles", titles);
return PARENTPATH + "title";
}
return "error";
} catch (Exception e) {
e.printStackTrace();
return "error";
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询