2007-04-19
spring mvc循序渐进(6)
关键字: spring第十八步——添加一下测试数据让它自动装载业务对象
我还不想添加任何从数据库加载业务对象的代码。我们仅仅使用spring的bean运用环境编制几个对象。我将简单把握需要的数据全部放到springapp-servlet.xml里。我同时添加我将在后面创建的整个信息池配置('messages.properties')。
springapp/war/WEB-INF/springapp-servlet.xml
- xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
- <bean id="springappController" class="web.SpringappController">
- <property name="productManager">
- <ref bean="prodMan"/>
- property>
- bean>
- <bean id="prodMan" class="bus.ProductManager">
- <property name="products">
- <list>
- <ref bean="product1"/>
- <ref bean="product2"/>
- <ref bean="product3"/>
- list>
- property>
- bean>
- <bean id="product1" class="bus.Product">
- <property name="description"><value>Lampvalue>property>
- <property name="price"><value>5.75value>property>
- bean>
- <bean id="product2" class="bus.Product">
- <property name="description"><value>Tablevalue>property>
- <property name="price"><value>75.25value>property>
- bean>
- <bean id="product3" class="bus.Product">
- <property name="description"><value>Chairvalue>property>
- <property name="price"><value>22.79value>property>
- bean>
- <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
- <property name="basename"><value>messagesvalue>property>
- bean>
- <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
- <property name="mappings">
- <props>
- <prop key="/hello.htm">springappControllerprop>
- props>
- property>
- bean>
- <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
- <property name="viewClass"><value>org.springframework.web.servlet.view.JstlViewvalue>property>
- <property name="prefix"><value>/WEB-INF/jsp/value>property>
- <property name="suffix"><value>.jspvalue>property>
- bean>
- beans>
第十九步——添加消息池绑定同时添加一个clean target到build.xml
I create a 'messages.properties' file in the war/WEB-INF/classes directory. This properties bundle so far has three entries matching the keys specified in the
我在war/WEB-INF/classes目录下创建了一个“messages.properties'”文件。这个消息捆绑(properties bundle)目前已经有三个匹配hello.jsp的
- title=SpringApp
- heading=Hello :: SpringApp
- greeting=Greetings, it is now
运行ant,重启tomcat,浏览http://127.0.0.1:8080/springapp/hello.htm,就看到改动了
发表评论
- 浏览: 7619 次

- 详细资料
搜索本博客
最新评论
-
spring mvc循序渐进(6)
辞职了,没时间写了
-- by aninfeel -
spring mvc循序渐进(6)
楼主继续后面的哈,测试那里有点没看懂
-- by gowhere -
javascript控制html dom
Dom.这是Dom规范要实现的东西. 不只Javascript, 在.net里操 ...
-- by 白发红颜 -
javascript控制html dom
像getElementById(),getElementsByTagName() ...
-- by just4you -
javascript控制html dom
w3cshcool办得不错,其文章言骇意简--当初学XML,用WEBZIP把整个 ...
-- by sp42






评论排行榜