构造函数注入问题?

时间:2011-08-07 09:54:29

标签: spring

我想尝试实现构造函数注入但是我没有设置值,以下是我的bean配置文件

<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 http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd" xmlns:tx="http://www.springframework.org/schema/tx">

        <bean id="helloWebWorldForm"
               class="com.driven.solutions.controllers.HelloWebWorldFormController">
         <property name="sessionForm"><value>true</value></property>

         <property name="commandName"><value>webUserInfo</value></property>
          <property name="commandClass"><value>com.driven.solutions.commandClasses.WebUserInfo</value> </property>

           <property name="formView"><value>helloWebUser</value></property>
            <property name="successView"><value>greetings.htm</value></property>
       </bean> <!--  configures the controller !-->

           <bean id="greetingsController" class="com.driven.solutions.controllers.GreetingsController"/>
           <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            <property name="mappings">
             <props> <!--  maps web pages to the controllers-->
              <prop key="/helloWebUser.htm">helloWebWorldForm</prop>
              <prop key="/greetings.htm">greetingsController</prop>
             </props>
           </property>
         </bean>
         <bean id="user" class="com.driven.solutions.commandClasses.WebUserInfo" >
          <constructor-arg index="0" type="java.lang.String" value="raaj"/>
          <constructor-arg index="1" type="java.lang.String" value="arna"/>
          <constructor-arg index="2" type="int" value="21"/>
          <constructor-arg index="3" type="java.lang.String" value="andhra"/>

         </bean>

<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
     <property name="viewClass"> <value>org.springframework.web.servlet.view.JstlView</value>
      </property> <!-- configures prefix and suffix for web pages inside the added jsp folder  -->
       <property name="prefix"><value>/WEB-INF/jsp/</value></property>
        <property name="suffix"><value>.jsp</value></property>
</bean>
</beans>

0 个答案:

没有答案