I use Tiles 2 in my Spring 3 MVC application i defines the form:
<definition name="addcompany.htm" extends="baseLayout"> <put-attribute name="title" value="Add Company"/> <put-attribute name="body" value="/WEB-INF/jsp/addcompany.jsp"/> </definition>
and:
addcompany.(class)=org.springframework.web.servlet.view.tiles2.TilesView addcompany.url=addcompany.htm
And here is my controller:
@RequestMapping(value="/addcompany.htm", method=RequestMethod.GET) public ModelAndView getForm() { logger.info("Getting form!"); ModelAndView mav = new ModelAndView(); logger.info("Loading form"); Company cmp = new Company(); mav.addObject("company",cmp); mav.setViewName("addcompany"); return mav; } @RequestMapping(value="/addcompany.htm", method=RequestMethod.POST) public String postForm(@ModelAttribute("company") Company cmp) { logger.info("post form!"); companyService.saveCompany(cmp); logger.info("post form"); return "redirect:tiles:companylist";
Using Tiles2, REDIRECT does not work.
Any idea how to redirect after a successful POST using Tiles?
thanks
EDIT: The solution is to add this to views.properties:
redirectcompanylist.(class)=org.springframework.web.servlet.view.RedirectView redirectcompanylist.url=/companylist.htm
And return the redirectcompanylist to the controller
source share