PDA

View Full Version : how to use view


ericdeng
Sep 29th, 2004, 09:09 PM
how to use "org.springframework.web.servlet.view.ResourceBundl eViewResolver"? who can give me a example about views.xml ? And I want to know whether the "views.properties" must be in "/WEB-INF/classes/"? it can be put another location ? and how can I configurate it ?
thanks a lot .:)

irbouho
Sep 29th, 2004, 09:25 PM
how to use "org.springframework.web.servlet.view.ResourceBundl eViewResolver"?
Take a look at countries sample from Spring distribution.
And I want to know whether the "views.properties" must be in "/WEB-INF/classes/"?
views.properties is looked for in the class apth.
it can be put another location ?
You can put it in a package inside your class path.
and how can I configurate it ?
<bean id="viewResolver" class="org.springframework.web.servlet.view.ResourceBundl eViewResolver">
<property name="basename"><value>org/mycompany/demo/views</value></property>
<property name="defaultParentView"><value>modelView</value></property>
</bean>


HTH

ericdeng
Sep 29th, 2004, 10:09 PM
thanks for your reply ^-^
then , maybe I can't put the "view.properties" in "web-inf/view"

davison
Sep 30th, 2004, 05:15 AM
thanks for your reply ^-^
then , maybe I can't put the "view.properties" in "web-inf/view"
no, because then it won't be in the classpath as Omar already explained. WEB-INF/classes and any jar file in WEB-INF/lib is automatically added to the classpath by the servlet container. This is standard Java and servlet API semantics.

If you are averse to storing your config file in the classpath, consider using XmlViewResolver - you can store the file anywhere you like.
<bean
id="viewResolver"
class="org.springframework.web.servlet.view.XmlViewResolv er">
<property name="location">
<value>/WEB-INF/views.xml</value>
</property>
</bean>
Regards,

ericdeng
Sep 30th, 2004, 09:14 AM
thanks davison.
but I can't find the views.xml in spring samples, and I google it ,but no result. how can I configurate the views.xml ?

davison
Sep 30th, 2004, 11:21 AM
the file uses the same syntax as other Spring XML config files so you can reuse your knowledge.

<bean
id="someView"
class="org.springframework.web.servlet.view.velocity.Velo cityView">
<property name="url"><value>sometemplate.vm</value></property>
</bean>

Regards,