File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Application Frameworks and the fly likes Why we need a resolver ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Why we need a resolver ?" Watch "Why we need a resolver ?" New topic
Author

Why we need a resolver ?

Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

Hi.
If I'm using JSP and Servlets with Spring, why I have to use a view resolver such :

And if I want to use JSP&Servlets, which resolver I have to use (or when to use it) :
org.springframework.web.servlet.view.ResourceBundleViewResolver
or
org.springframework.web.servlet.view.InternalResourceViewResolver
Thanks.
Ken Krebs
Ranch Hand

Joined: Nov 27, 2002
Posts: 451
ViewResolvers exist to allow Controllers (you are using Spring Controllers aren't you ?) to specify views by logical names rather than physical url's directly. This makes it much easier to refactoryour UI code or to change the type of view you want to render, say from JSP to PDF. If you make a change, you won't have change the Controller, just the mapping.

InternalResourceViewResolver is a subclass of UrlBasedViewResolver that supports JSP's. UrlBasedViewResolver can map view names to views without having to supply an explicit mapping. You can just use naming conventions to do the mapping. ResourceBundleViewResolver is very convenient if internationalization is needed or may ever be needed. The Java ResourceBundle class javadoc has more info regarding internationalization naming conventions. Spring's ResourceBundleViewResolver provides support for those file naming conventions.

The Spring javadocs and reference documentation are really very good andprovide much more detail about this and other issues than I can. You should try reading them.


kktec<br />SCJP, SCWCD, SCJD<br />"What we observe is not nature itself, but nature exposed to our method of questioning." - Werner Heisenberg
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

(you are using Spring Controllers aren't you ?)

Well, I'm using JSP&Servlets (not Spring MVC or any other framework), How can I use Spring controllers ?
Even if I'm using regular JSP and Servlets, I have to use Spring controllers ?
[ January 20, 2006: Message edited by: John Todd ]
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
John, if you're not using Spring Controllers then you don't need to use a Spring ViewResolver either. What makes you think you need one? Are you getting some kind of an exception implying something along those lines?


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

Please correct me if I'm wrong :
Spring controllers are part of Spring MVC framework and we use it only when we use Spring MVC framework.
Not with JSF, Struts, Tapestry or even regular JSP and Servlets ....
Well, please be patient, I'm new with Spring.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why we need a resolver ?