spring中配置bean及引用

[color=darkred][size=medium]
  spring 中配置一个list类型的bean之后,若想在类里面将其注入就不能用一般的@Inject标签了,
如下:配置简单的list
   <util:list id="systemAccountListZTL" list-class="java.util.ArrayList"
value-type="java.lang.String">
<value>xiaobo</value>
   </util:list>
   引用的时候须要用标签:
@Resource(name="systemAccountListZTL")
private List<String> systemAccountListZTL;
此时如果用@Inject就会报错
   或者复杂的list配置如下
    <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:batch="http://www.springframework.org/schema/batch"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:jms="http://www.springframework.org/schema/jms" xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-3.0.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">

<bean id="info" class="com.book511.service.product.ColumnInfo">
<property name="name" value="code" />
<property name="comments" value="请输入编号" />
<property name="required" value="true" />
<property name="type">
<value type="com.book511.service.product.ColumnInfo$Type">INPUT</value>
</property>
<property name="regex">
<null />
</property>
<property name="options">
<list>
<value>a</value>
<value>b</value>
</list>
</property>
</bean>


<util:list id="StorageAddInfos">
<bean class="com.book511.service.product.ColumnInfo">
<property name="name" value="进价" />
<property name="comments" value="1、必填项。2、需为有效价格格式" />
<property name="required" value="true" />
<property name="type">
<value type="com.book511.service.product.ColumnInfo$Type">INPUT</value>
</property>
<property name="regex" value="^\d+(\.\d+)?$"/>
</bean>
<bean class="com.book511.service.product.ColumnInfo">
<property name="name" value="入库数量" />
<property name="comments" value="1、必填项。2、只能录入正整数" />
<property name="required" value="true" />
<property name="type">
<value type="com.book511.service.product.ColumnInfo$Type">INPUT</value>
</property>
<property name="regex" value="^[0-9]*[1-9][0-9]*$"/>
</bean>
<bean class="com.book511.service.product.ColumnInfo">
<property name="name" value="入库原因" />
<property name="comments" value="" />
<property name="required" value="true" />
<property name="type">
<value type="com.book511.service.product.ColumnInfo$Type">RADIO</value>
</property>
<property name="regex">
<null />
</property>
<property name="options">
<list>
<value>外购</value>
<value>内调</value>
<value>赠送</value>
<value>盘盈</value>
</list>
</property>
</bean>
<bean class="com.book511.service.product.ColumnInfo">
<property name="name" value="供货单位" />
<property name="comments" value="" />
<property name="required" value="false" />
<property name="type">
<value type="com.book511.service.product.ColumnInfo$Type">RADIO</value>
</property>
<property name="regex">
<null />
</property>
<property name="options">
<list>
<value>人民邮电出版社</value>
<value>机械出版社</value>
</list>
</property>
</bean>
</util:list>
</beans>

    


   
[/size][/color]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值