Results 1 to 6 of 6

Thread: how to use view

  1. #1
    Join Date
    Sep 2004
    Location
    china
    Posts
    5

    Default 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. #2
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    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
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  3. #3
    Join Date
    Sep 2004
    Location
    china
    Posts
    5

    Default

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

  4. #4
    Join Date
    Aug 2004
    Location
    London, UK
    Posts
    339

    Default

    Quote 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,
    Darren Davison.
    Public Key: 0xE855B3EA

  5. #5
    Join Date
    Sep 2004
    Location
    china
    Posts
    5

    Default

    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 ?

  6. #6
    Join Date
    Aug 2004
    Location
    London, UK
    Posts
    339

    Default

    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,
    Darren Davison.
    Public Key: 0xE855B3EA

Similar Threads

  1. Replies: 9
    Last Post: Nov 1st, 2005, 10:36 PM
  2. Replies: 0
    Last Post: Aug 29th, 2005, 03:23 PM
  3. PageCompononentListener Hooks...JIRA issue?
    By amcauley in forum Swing
    Replies: 9
    Last Post: Apr 15th, 2005, 06:10 AM
  4. Content Provider vs View Model
    By Martin Kersten in forum Swing
    Replies: 21
    Last Post: Mar 10th, 2005, 02:25 PM
  5. refreshing the view
    By Jurijus Jarmakas in forum Swing
    Replies: 2
    Last Post: Feb 8th, 2005, 05:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •