I have the simplest Tiles configuration in my Spring MVC web app:
<!-- Default Main Template -->
<definition name="mainTemplate" template="/WEB-INF/views/main.jsp">
<put-attribute name="title" value="My title" type="string" />
<put-attribute name="header" value="/WEB-INF/templates/header.jsp" />
<put-attribute name="body" value="/WEB-INF/templates/blank.jsp" />
<put-attribute name="footer" value="My footer" type="string" />
</definition>
<definition name="home" extends="mainTemplate">
<put-attribute name="body" value="/WEB-INF/templates/home.jsp" />
</definition>
<definition name="scadenze" extends="mainTemplate">
<put-attribute name="body" value="/WEB-INF/templates/scadenze.jsp" />
</definition>
My standard “/home” mapping controller returns a new ModelAndView("home"); and all goes fine.
Now I want to put a $("#header").load("/pathtoheadercontrollerurlmapping"); for reloading one part of my page the ajax way.
What does my controller method have to return? How can I return simply my header.jsp and achieve my goal?
One way which i am thinking is you should not bring the whole jsp in that ajax call rather you should bring a json string with which you can build the html in the jquery part. The json will have the values from the server side (may be from database or file or whatever which is dynamic). After getting the json reponse, you should mainpulate that in the jquery ajax response and build the html context and set it back in the header. Just a thought.