Announcement Announcement Module
Collapse
No announcement yet.
how to use view Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to use view

    how to use "org.springframework.web.servlet.view.ResourceBund leViewResolver"? 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 .

  • #2
    how to use "org.springframework.web.servlet.view.ResourceBund leViewResolver"?
    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 ?
    Code:
    	<bean id="viewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
    		<property name="basename"><value>org/mycompany/demo/views</value></property>
    		<property name="defaultParentView"><value>modelView</value></property>
    	</bean>
    HTH

    Comment


    • #3
      thanks for your reply ^-^
      then , maybe I can't put the "view.properties" in "web-inf/view"

      Comment


      • #4
        Originally posted by ericdeng
        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.
        Code:
        <bean 
          id="viewResolver" 
          class="org.springframework.web.servlet.view.XmlViewResolver">
          <property name="location">
            <value>/WEB-INF/views.xml</value>
          </property>
        </bean>
        Regards,

        Comment


        • #5
          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 ?

          Comment


          • #6
            the file uses the same syntax as other Spring XML config files so you can reuse your knowledge.

            Code:
            <bean
              id="someView" 
              class="org.springframework.web.servlet.view.velocity.VelocityView">    	
              <property name="url"><value>sometemplate.vm</value></property> 
            </bean>
            Regards,

            Comment

            Working...
            X