• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

[spring] can XmlViewResolver resolve to a jsp?

 
Ranch Hand
Posts: 2102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The examples for XmlViewResolver and XmlFileViewResolver that I saw, resolves into rss, xls, and pdf only. Can the view from these resolvers be jsps?
 
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
XmlViewResolver can use for JSPs. Actually, XmlViewResolver just for specifying resource location in XML file.

But I don't know what XmlFileViewResolver is.
 
Jesus Angeles
Ranch Hand
Posts: 2102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Kengkaj Sathianpantarit wrote:XmlViewResolver can use for JSPs. Actually, XmlViewResolver just for specifying resource location in XML file.

But I don't know what XmlFileViewResolver is.



Nevermind about XmlFileViewResolver. It could be a mistype in the book that I am reading.

Can you show me how the declaration is done, mapping to a jsp, using XmlViewResolver?
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. The following configuration uses XmlViewResolver to redirect to a controller which will dispatch to a JSP.

views.xml
<bean id="newPersonSuccess"
class="org.springframework.web.servlet.view.RedirectView">
<property name="contextRelative" value="true" />
<property name="url" value="/personSuccess" />
</bean>



<bean name="/personSuccess"
class="org.springframework.web.servlet.mvc.UrlFilenameViewController" />



I copy from Expert Spring MVC and Web Flow book.
 
Jesus Angeles
Ranch Hand
Posts: 2102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like we will redirect to another controller, which will later result into a jsp.

But that involves calling 2 controllers.

At the point views.xml is consulted, the Model is already available. I just need to resolve to a jsp, just like the InternalResourceViewResolver. This solution will again go to another controller.

(Much like struts, I want the flexibility to have the View name not necessarily the same as the jsp prefix.)

Any idea how to do it?
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know, but using controller give you advantage to abstract real path of JSPs, you can specify prefix and suffix.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!