Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[spring] can XmlViewResolver resolve to a jsp?

 
Jesus Angeles
Ranch Hand
Posts: 2068
  • 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?
 
Hong Anderson
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: 2068
  • 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: 2068
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic