• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Beginner question about how UrlBasedViewResolver work in particular case

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I have a question about how Spring solve view in some special cases.

Normaly in mu servlet configuration file I have something like:



So that simply mean that If my servlet receive the logical view name (for example contactList) by one of my controller bean, this view is resolved in the following way: /WEB-INF/jsp/contactList.jsp and this view is rendered...ok...this look simple.

Now I am studing the following example that uses Tiles Framework that divides website into pieces of reusable template that are being rendered among different web pages.

So now my spring-servlet.xml configuration file (the file used to configure my servlet) is this one:



As you can see I in this configuration file in the UrlBasedViewResolver bean (having id=viewResolver) I have not the behavior for which every view name returned from a handler will be translated to a JSP resource (for example: "myView" -> "/WEB-INF/jsp/myView.jsp") but I have the configuration for Tiles Framework integration in Spring...

So my question is: how does Spring know which page to render?

I'm reasoning about this fact and I think that maybe the process works like this:

In tiles.xml file there is the configuration of Tiles Framework, so in this file I have how a GENERIC PAGE look like,in the specific case of the example I have that my page is divided into: a title, an header, a menu, a body, a footer.

In this configuration file as well as define how a generic page looks, I am defining also how the contact page look, I'm basically putting the contact.jsp view inside the body section...

Now the view render process is the following one:

1) In web.xml file I have that the welcome file is a file named index.jsp

2) Inside the index.jsp I simply nexecute a forwarding to a "contacts.html" page, using the tag <jsp:forward page="contacts.html"></jsp:forward>

3) The contact.html file is managed by the showContacts() method inside my controller, this method return a ModelAndView object that contain the logical view name: "contact"

4) Now Spring MVC use the UrlBasedViewResolver bean and discover that in this case he is using Tiles Framework so look insite Tiles Configuration file (tiles.xml)

5) In tiles.xml file there is how the contacts.html have to be make (using the contac.jsp page inside the body section) and render it

I think that this reasoning could be right...but I am not totaly sure aboute it...I have many doubts about the possibility of thinking in the wrong way...it is quite hard reasoning in Spring way for a beginner...

An other question is: but this Tiles framework is very popular nowadays? it seems to me a rather obsolete technology and I think that we can do better using other tecnology such as xhtml file...what do you think about?

Tnx
Andrea
 
Could you hold this puppy for a sec? I need to adjust this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic