ParameterizableViewController example in Spring 2.5 Web MVC framework.
This controller is use to redirect the page in the Spring 2.5 Web MVC applications. This controller doesn't require controller class. This controller provides an alternative to sending a request straight to a view such as a JSP. we will configure just declared the ParameterizableViewController bean and set the view name through the "viewName" property.
Now we will used ParameterizedViewController for control the behavior of the application.
Now we will create a index.jsp that will have a hyperlink that linked with the parameterizableviewcontroller.html. If user click on this link the request will generate for the parameterizableviewcontroller.html. The code of the index.html is:
Now we will configure the DispatcherServlet in the web.xml. The DispatcherServlet will be configure to process all the request that have ending with .html. In this web.xml we will also define how to use spring.tld for the Spring 2.5 Web MVC application. Here is the code of the web.xml
Now we will create a xml file inside the project WEB-INF folder with dispatcher-servlet.xml name. This is the main configuration file for the Spring web application. In this file all request will configure with the particular controller by beans setting and urlMapping defined in it. The code of the dispatcher-servlet.xml is:
If the parameterizableviewcontroller.html request will occurred then dispatcher-servlet.xml will provide the controller for control this request that's name parameterizableController. But parameterizableController is derived by ParameterizableViewController that redirect the page by using viewName property.
Now we will create ParameterizableController.jsp page that is display as a user interface after redirect page by the ParameterizableViewController. The code of the ParameterizableController.jsp is:
Now we will run this application and see the output like:
Now click on this link and see, the application will display like: