I am using Tiles 2 in my Spring 3 MVC application i defines a 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"; // How do i redirect?
}
Using Tiles2, the REDIRECT doesnt work.
Any idea how to redirect after a successful POST using Tiles ?
thanks
EDIT : Solution is to add this in the views.properties :
redirectcompanylist.(class)=org.springframework.web.servlet.view.RedirectView
redirectcompanylist.url=/companylist.htm
And return redirectcompanylist in the controller
You'll have to use the URL path when redirecting. Like this: return redirect:/companylist.htm
which then goes to the corresponding method in the controller.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With