目录
页面跳转
1.返回字符串:
//视图解析器
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
@RequestMapping("/save10")
public String save10(){
return "index";
}
2.ModelAndView方式
@RequestMapping("/save11")
public ModelAndView save11(){
ModelAndView modelAndView=new ModelAndView();
modelAndView.addObject("username","zhuang");
modelAndView.setViewName("success");
return modelAndView;
}
@RequestMapping("/save12")
public ModelAndView save12(ModelAndView modelAndView){
modelAndView.addObject("username","zhuang");
modelAndView.setViewName("success");
return modelAndView;
}
@RequestMapping("/save12")
public String save12(Model model){
model.addAttribute("username","zhuang");
return "success";
}