91-9990449935 0120-4256464 |
Spring MVC Tiles ExampleSpring provides integration support with apache tiles framework. So we can simply manage the layout of the spring mvc application by the help of spring tiles support. Advantage of Tiles support in Spring MVC
Spring MVC Tiles ExampleLet's see a simple spring mvc tiles example. Required Jar filesTo run this example, you need to load:
You need to put these jar files inside the WEB-INF/lib directory. Directory StructureLet's see the files of spring tiles example in eclipse. Index Pageindex.jspController classesHelloWorldController.java ContactController.javaForm classContact.javaweb.xmlIn this xml file, we are specifying the servlet class DispatcherServlet that acts as the front controller in Spring Web MVC. All the incoming request for the html file will be forwarded to the DispatcherServlet. web.xmlspring-servlet.xml fileThis is the important configuration file where we need to specify the ViewResolver and View components. The context:component-scan element defines the base-package where DispatcherServlet will search the controller class. Here, the UrlBasedViewResolver class is used for the ViewResolver. The prefix+string returned by controller+suffix page will be invoked for the view component. This xml file should be located inside the WEB-INF directory. spring-servlet.xmltiles.xml filetiles.xmlView Componentshello.jsp contact.jsp header.jsp footer.jsp menu.jsp layout.jspOutput
Next TopicRemoting In Spring Framework
|