spring mvc action 跳转

yupi0 2011-01-10

returnString

@RequestMapping(params="action=delete")

publicStringdelete(@RequestParam("type")

inttype,@RequestParam("url")

Stringurl){

return"redirect:/console/visitorPolicyList.do?action=list&type=1";

}

ModelAndView

eturnNewModelAndView(newRedirectView(“xxx.jsp“));

或者returnNewModelAndView(newRedirectView(getSuccessView()));

//配制

SpringMvc默认的是forward方式(mvc框架都是这样),IE地址栏内的URL肯定不变了。用redirect方式倒是可以,在Controller里面returnnewModelAndView(newRedirectView(getSuccessView())).如果用InternalResourceViewResolver的话更简单一些,把view的名字加个“redirect:“前缀就行了(redirect:index.jsp),这样的好处是基于配置文件的。不过要传到页面上的对象怎么办?而且也暴露了view技术为jsp

相关推荐