Calling Controller from Tiles Template using Spring 3 -
i set apache tiles 2 in spring mvc 3 application.
i created template :
<definition name="baselayout" template="/web-inf/jsp/baselayout.jsp"> <put-attribute name="title" value="template"/> <put-attribute name="header" value="/web-inf/jsp/header.jsp"/> <put-attribute name="menu" value="/web-inf/jsp/menu.jsp"/> <put-attribute name="body" value="/web-inf/jsp/body.jsp"/> <put-attribute name="footer" value="/web-inf/jsp/footer.jsp"/> </definition>
and welcome page :
<definition name="welcome" extends="baselayout"> <put-attribute name="title" value="welcome"/> <put-attribute name="body" value="/web-inf/jsp/home.jsp"/> </definition>
and properties tile :
welcome.(class)=org.springframework.web.servlet.view.tiles2.tilesview welcome.url=welcome
and controller :
@requestmapping(value="/welcome", method=requestmethod.get) public modelandview home() { logger.info("welcome home yesssssss!"); modelandview mav = new modelandview(); logger.info("loading companies"); mav.addobject("companys", companyservice.loadcompanys()); mav.setviewname("welcome"); return mav; }
it works fine.
but how call controller within template file menu.jsp call controller 1 :
@requestmapping(value="/menu", method=requestmethod.get) public modelandview menu() { logger.info("get menu"); modelandview mav = new modelandview(); logger.info("loading menu"); mav.addobject("menu", menu.get()); mav.setviewname("menu"); return mav; }
any idea?
thanks
in order call 'menu' controller, need specify 'menu' in properties file corresponding url, has mapped controller (just did welcome).
may suggest use .htm views or .do forms etc.? without, it's easy confused if you're trying show view, or you're trying map request etc.
Comments
Post a Comment