开发Spring MVC应用程序(3-3)

王朝java/jsp·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

l 现在需要修改springapp-servlet.xml,定义新的表单和对应控制器

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"

"http://www.springframework.org/dtd/spring-beans.dtd">

<!--

- Application context definition for "springapp" DispatcherServlet.

-->

<beans>

<!-- Controller for the initial "Hello" page -->

<bean id="springappController" class="web.SpringappController">

<property name="productManager">

<ref bean="prodMan"/>

</property>

</bean>

<!-- Validator and Form Controller for the "Price Increase" page -->

<bean id="priceIncreaseValidator" class="bus.PriceIncreaseValidator"/>

<bean id="priceIncreaseForm" class="web.PriceIncreaseFormController">

<property name="sessionForm"><value>true</value></property>

<property name="commandName"><value>priceIncrease</value></property>

<property name="commandClass"><value>bus.PriceIncrease</value></property>

<property name="validator"><ref bean="priceIncreaseValidator"/></property>

<property name="formView"><value>priceincrease</value></property>

<property name="successView"><value>hello.htm</value></property>

<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>Lamp</value></property>

<property name="price"><value>5.75</value></property>

</bean>

<bean id="product2" class="bus.Product">

<property name="description"><value>Table</value></property>

<property name="price"><value>75.25</value></property>

</bean>

<bean id="product3" class="bus.Product">

<property name="description"><value>Chair</value></property>

<property name="price"><value>22.79</value></property>

</bean>

<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">

<property name="basename"><value>messages</value></property>

</bean>

<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">

<property name="mappings">

<props>

<prop key="/hello.htm">springappController</prop>

<prop key="/priceincrease.htm">priceIncreaseForm</prop>

</props>

</property>

</bean>

<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">

<property name="viewClass">

<value>org.springframework.web.servlet.view.JstlView</value>

</property>

<property name="prefix"><value>/WEB-INF/jsp/</value></property>

<property name="suffix"><value>.jsp</value></property>

</bean>

</beans>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航