导包基础:这了让服务器支持json 需要导入下面包
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.28</version>
</dependency>


这是一个基本类,++++++++++++++++++++++++++++++++++++++++++
package com.itheima.dao;

import java.lang.reflect.Array;
import java.util.*;

public class BookDaofff {
private int[] array;
private List<String> list;
private Set<String> set;
private Map<String, String> map;
private Properties properties;

public void setArray(int[] array){this.array = array;}
public void setList(List<String> list){this.list = list;}
public void setSet(Set<String> set){this.set = set;}
public void setMap(Map<String,String> map){this.map = map;}
public void setProperties(Properties properties){this.properties = properties;}

public void save(){
System.out.println("array"+ Arrays.toString(array));
System.out.println("list"+list);
System.out.println("set"+set);
System.out.println("map"+map);
System.out.println("properties"+ properties);
}

}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++配置类+++++++++++++++++++++++++++++++++++++++++++=
<?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:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
<bean id="BookDaofff" class="com.itheima.dao.BookDaofff">
<property name="array">
<array>
<value>100</value>
<value>200</value>
<value>300</value>
</array>
</property>
<property name="list">
<list>
<value>100</value>
<value>200</value>
<value>300</value>
</list>
</property>
<property name="set">
<set>
<value>100</value>
<value>200</value>
<value>300</value>
</set>
</property>
<property name="map">
<map>
<entry key = "country" value="china"/>
<entry key = "province" value="helan"/>
<entry key = "city" value="xxxxx"/>
</map>
</property>
<property name="properties">
<props>
<prop key = "country" >url</prop>
<prop key = "province">www</prop>
<prop key = "city" >heixxx</prop>
</props>
</property>
</bean>
</beans>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++使用类+++++++++++++++++++++++++++++++++++++++++=
package com.itheima.app;

import com.itheima.dao.BooDao;
import com.itheima.dao.BookDaofff;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Appfor {
public static void main(String[] args) {
ApplicationContext ctx = new ClassPathXmlApplicationContext("sp.xml");
BookDaofff bookDao = (BookDaofff) ctx.getBean("BookDaofff");
bookDao.save();
}
}
-+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++完结演示++++++++++++++++++++++++++++++++++++++++++++++++++++++++2022-7-22

spring 注入参数时为list map写法用例的更多相关文章

  1. spring注入参数详解

    spring注入参数详解 在Spring配置文件中, 用户不但可以将String, int等字面值注入到Bean中, 还可以将集合, Map等类型的数据注入到Bean中, 此外还可以注入配置文件中定义 ...

  2. 关于Spring注入参数到static静态参数失败问题处理。解决Autowired annotation is not supported on static fields的问题

    直接贴代码 把注入参数的注解加到set方法上面去即可. 因为这是一个工具类用到的config,所以一开始没有加@Component,还是依然为空,加上之后就正常能注入了

  3. FlushMode属性与transaction(spring注入的事务)

    一.参见hibernate的api http://tool.oschina.net/apidocs/apidoc?api=hibernate-3.6.10 http://tool.oschina.ne ...

  4. mybatis中collection子查询注入参数为null

    具体实现参照网上,但是可能遇到注入参数为null的情况,经过查阅及自己测试记录一下: 子查询的参数中,有<if test="">之类,需要指定别名,通过 http:// ...

  5. spring mvc 3.1的自动注入参数遇到的问题

    在网上下载了xheditor作为页面的编辑器,编辑内容后post到后台保存,后台方法用spring mvc的自动注入的方式接收参数. 这种方式在各个浏览器下运行良好,但是在ie11下发现,从word. ...

  6. MyBatis传入参数为list、数组、map写法(转载)

    MyBatis传入参数为list.数组.map写法 1.foreach简单介绍: foreach的主要用在构建in条件中,它可以在SQL语句中进行迭代一个集合. foreach元素的属性主要有item ...

  7. Spring属性注入、构造方法注入、工厂注入以及注入参数(转)

    Spring 是一个开源框架. Spring 为简化企业级应用开发而生(对比EJB2.0来说). 使用 Spring 可以使简单的 JavaBean 实现以前只有 EJB 才能实现的功能.Spring ...

  8. Spring 依赖注入(二、注入参数)

    注入参数基本分7类: 1.基本类型值 2.注入bean 3.内部bean 4.注入null值 5.级联属性 6.List,Set,Map集合的注入 7.properties文件的注入(和集合注入基本是 ...

  9. MyBatis传入参数为list、数组、map写法

    1.foreach简单介绍: foreach的主要用在构建in条件中,它可以在SQL语句中进行迭代一个集合. foreach元素的属性主要有item,index,collection,open,sep ...

  10. Spring中注入List,Set,Map,Properties的xml文件配置方法

    下面的例子展示了如何注入 List – <list/> Set – <set/> Map – <map/> Properties – <props/> ...

随机推荐

  1. 使用emmylua调试slua

    使用emmylua调试slua的方法 在lua的入口中加上emmylua的debug代码 在slua的LuaState.loaderDelegate委托中,添加判断如果是load_file_name= ...

  2. 强化学习从基础到进阶-常见问题和面试必知必答[5]::梯度策略、添加基线(baseline)、优势函数、动作分配合适的分数(credit)

    强化学习从基础到进阶-常见问题和面试必知必答[5]::梯度策略.添加基线(baseline).优势函数.动作分配合适的分数(credit) 1.核心词汇 策略(policy):在每一个演员中会有对应的 ...

  3. 探索C语言中的Shellcode从提取到执行

    ShellCode是一种独立于应用程序的机器代码,通常用于实现特定任务,如执行远程命令.注入恶意软件或利用系统漏洞.在网络安全领域,研究Shellcode是理解恶意软件和提高系统安全性的关键一环.本文 ...

  4. html的input type=file

    文件上传:https://www.zhangxinxu.com/wordpress/2015/11/html-input-type-file/ some与every的使用:https://blog.c ...

  5. 关于laravel路由无法访问(nginx)

    laravel路由无法访问 被这个问题折腾了 好几次了,记录一下希望可以帮到后面的朋友 在laravel路由中配置好了之后无法访问的问题有可能是因为在本地服务配置的问题(我使用的是nginx服务器) ...

  6. 教你用JavaScript实现粘性导航

    案例介绍 欢迎来的我的小院,我是霍大侠,恭喜你今天又要进步一点点了!我们来用JavaScript编程实战案例,做一个粘性导航.移动页面导航仍在页面上方.通过实战我们将学会scrollY属性.offse ...

  7. 打造个性化日历:Python编程实现,选择适合你的方式!

    在本文中,我们将使用Python编写一个简单的日历程序.虽然市面上已经存在现成的日历功能,并且有第三方库可以直接调用实现,但我们仍然希望通过自己编写日历程序来引出我认为好用的日历实现.希望这篇文章能够 ...

  8. 案例:推进GTID解决MySQL主主不同步问题

    之前文章介绍过MySQL修改lower_case_table_names参数,如果之前大写存储的表将无法识别,需要特殊处理. 最近遇到一例应用开发人员在修改这个参数之后,为了清除之前大写存储的表,做了 ...

  9. Linux shell的while循环

    while循环 #!/bin/bash #其中":"表示while循环的条件永远为真的意思 while : do read -p "Enter a number [1-5 ...

  10. Python 中获取文件名

    Python 获取文件名import osimport sys # ①获取当前文件名os.path.basename(__file__)# ②获取程序启动文件名os.path.basename(sys ...