>### 1.出现特殊字符,可以使用 <![CDATA[]]> 把字面值包裹起来
~~~
<bean id="d4" class="cn.li.lesson3.Dog">
<!-- 使用子节点和 <![CDATA[<小黑>]]>给value设置特殊字符-->
<constructor-arg index="0">
<value><![CDATA[<小黑>]]></value>
</constructor-arg>
</bean>
~~~
>### 2.ref 引用其他的bean
~~~
<!-- 此时ref属性的值 就是你要引用得bean的id... -->
<property name="pet" ref="dog"></property>
<!-- 或者 -->
<property name="pet">
<ref bean="dog"></ref>
(或者直接写成<ref bean="dog"/>)
</property>
~~~
>### 3.内部bean不需要设置任何 id 或 name 属性 ,不能使用在任何其他地方
~~~
<property name="pet">
<!-- 内部 Bean 声明直接包含在 <property> 或 <constructor-arg> 元素里,
不需要设置任何 id 或 name 属性
-->
<bean class="com.igeek.demo3.Pet">
<property name="petName" value="小橘"></property>
<property name="petType" value="猫"></property>
</bean>
</property>
~~~
>### 4.注入null值,使用<null/>标签
~~~
<constructor-arg name="name">
<null/>
</constructor-arg>
~~~
>### 5.null值以及级联属性的注入
~~~
<bean id="timo" class="com.igeek.demo3.Pet">
</bean>
<!-- 添加有参构造器,不要忘记添加无参构造器 -->
<bean id="xl" class="com.igeek.demo3.Person">
<constructor-arg name="name">
<null/>
</constructor-arg>
<constructor-arg name="age" value="20"></constructor-arg>
<constructor-arg name="pet" ref="timo"></constructor-arg>
<!-- 为级联属性赋值 。前提是上面的pet属性不能为null -->
<property name="pet.petName" value="提莫"></property>
<property name="pet.petType" value="LOL"></property>
</bean>
~~~
>### 6.配置集合类型的属性(List,Array,Set)
~~~
<bean id="dog" class="com.igeek.demo4.Pet">
<property name="petName" value="大黄"></property>
<property name="petType" value="犬"></property>
</bean>
<bean id="cat" class="com.igeek.demo4.Pet">
<property name="petName" value="小橘"></property>
<property name="petType" value="猫"></property>
</bean>
<bean id="tom" class="com.igeek.demo4.Person">
<property name="pets">
<!--
如果数据类型为数组,也是使用<list>标签进行配置。
如果是Set集合,使用<set>标签进行配置。
(里面内容的配置方式都相同。)
-->
<list>
<ref bean="dog"/>
<ref bean="cat"/>
<null/>
<bean id="snake" class="com.igeek.demo4.Pet">
<property name="petName" value="大象"></property>
<property name="petType" value="蛇"></property>
</bean>
</list>
</property>
</bean>
~~~
>### 7.配置map类型
~~~
<bean id="jack" class="com.igeek.demo4.Person">
<property name="map">
<map>
<entry key="aa" value-ref="cat"></entry>
<entry key="bb" value-ref="dog"></entry>
</map>
</property>
</bean>
~~~
>### 8.配置properties类型
~~~
<bean id="testpros" class="com.igeek.demo4.Person">
<property name="pros">
<props>
<prop key="user">root</prop>
<prop key="password">root123</prop>
<prop key="jdbcUrl">jdbc:mysql:///test</prop>
<prop key="driverClass">com.mysql.jdbc.Driver</prop>
</props>
</property>
</bean>
~~~
>### 9.配置工具类集合
~~~
<!-- 首先导入util命名空间 -->
<?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:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd">
</beans>
<util:list id="pets">
<ref bean="cat"/>
<ref bean="dog"/>
</util:list>
<bean id="p4" class="cn.li.lesson5.Person">
<property name="pets">
<ref bean="pets"/>
</property>
</bean>
~~~
>### 10.使用p命名空间
~~~
<!-- 首先导入p命名空间 -->
xmlns:p="http://www.springframework.org/schema/p"
<bean id="p1" class="cn.li.lesson6.Person" p:name="玨网" p:age="20" p:pet-ref="pet">
</bean>
<bean id="pet" class="cn.li.lesson6.Pet">
<property name="name" value="鹦鹉"></property>
<property name="type" value="鸟"></property>
</bean>
<!-- 使用p命名空间(spring 2.5版本引入的) 可以简化bean的配置 -->
~~~
>### 11.自动装配
~~~
autowire = "byName" || "byType" 不推荐使用。
<!--
可以通过autowire属性设置bean的自动装配 。
byName 根据bean的名字和bean,setter风格的属性名进行自动装配,如有匹配则自动装配,没有不装配。
byType 根据bean的类型,和当前bean属性的类型进行自动装配。如果ioc容器有1个以上类型匹配的bean的时候,则会抛出异常。
constructor 当前bean中有多个构造器的时候 会很复杂不推荐使用该方式。
自动装配的弊端。
1.autowire属性是配置在bean级别的,如果只希望装配个别属性,则不够灵活。
2.要么根据类型 要么根据名字自动装配 不能两个一起使用。
在使用spring整合第三方框架的时候 会使用autowire 。。。
-->
<!-- <bean id="person" class="cn.li.lesson6.Person" p:name="tom" p:age="20" autowire="byType"></bean>
<bean id="timo" class="cn.li.lesson6.Pet" p:name="猪八戒" p:type="pig"></bean> -->
<bean id="p" class="cn.li.lesson6.Person" p:name="tom" p:age="20" autowire="byName"></bean>
<bean id="pet" class="cn.li.lesson6.Pet" p:name="猪八戒" p:type="猪"></bean>
~~~
- spring
- 1.spring第一天
- 1.1 安装spring插件(spring tool suite)
- 1.2 spring概述
- 1.3 控制反转&依赖注入
- 1.4 springIOC容器
- 1.5 依赖注入的四种方式
- 1.6 配置bean的细节
- 1.7 bean之间的关系
- 1.8 bean作用域
- 1.9 补充:创建对象的几种方法
- 1源代码位置
- 2.spring第二天
- 2.1 使用外部属性文件
- 2.2 spEL
- 2.3 bean的生命周期
- 2.4 通过工厂方式配置bean
- 2.5 基于注解的方式配置bean
- 2.6 组件装配
- 2.7 静态代理
- 2.8 动态代理
- 2.9 Cglib代理
- 2源代码位置
- 3. spring第三天
- 3.1 springAOP
- 3.1.1 AOP简介
- 3.1.2 为什么使用AOP
- 3.1.3 AOP关键术语
- 3.1.4 AOP图解
- 3.1.5 springAOP实现步骤
- 3.1.6 SpringAOP实现原理:
- 3.1.7 AOP的好处
- 3.1.8 AOP在实际项目中的主要应用
- 3代码地址
- 3.1.9 纯注解版配置aop的方式
- 3.2 maven环境搭建
- 附IDEA激活码
- 4. spring第四天
- 4.1 c3p0事务
- 4.2 命令窗口事务
- 4.3 c3p0连接池设置
- 4.4 事务中的一些基本概念
- 4.5 事务的传播行为
- 4.6 自定义异常
- 4.7 spring整合Junit单元测试
- 4.8 JdbcTemplate(附源代码)
- 事务源代码
- 4.9 纯注解tx
- 4.10 基于xml配置事务
- 0. jsp页面修改编码方式
- 0.1 eclipse配置tomcat
- 0.单例模式-饱汉模式
- 0.单例模式-饥汉模式
- springMVC
- 1. springmvc第一天
- 1.1 springMVC概述
- 1.2 springmvc框架搭建及第一个应用程序
- 1.3 @RequestMapping
- 1.4 RequestMapping修饰类
- 1.5 RequestMapping精准化映射
- 1.6 Ant风格URL
- 1.7 带有占位符的url映射
- 1.8 REST风格
- 1.9 RequerstParam获取请求正文
- 2. springmvc第二天
- 2.1 优化
- 2.2 POJO绑定请求参数
- 2.3 RequestHeader获取请求报头信息
- 2.4 CookieValue获取Cookie信息
- 2.5 获取原生ServletAPI
- 2.6 ModelAndView处理模型数据
- 2.7 Map、Model、ModelMap处理模型数据
- 2.8 @SessionAttributes注解
- 2.9 @ModelAttribute无返回值方法及方法入参
- 2.10 @ModelAttribute修饰有返回值类型的方法
- 代码地址
- 3. springmvc补充
- 3-1 springmvc工作原理
- 3-2 springmvc form表单提交中文乱码
- 3-3 数据的格式化
- 3-4 自定义类型转换器
- 3-5 其他知识点
- 3-6 crud代码
- 3-7 @DateTimeFormat日期格式化
- 3-8 数据验证的概念及JSR303验证
- 3-9 Hibernate-Validator验证框架
- 3-10 Controller捕获错误消息
- 3-11 errors标签在页面中获取错误消息
- 3-12 错误消息的定制及国际化
- 3-13 自定义拦截器
- 3-14 Java代码中获取国际化信息
- 3-15 超级链接设置国际化
- 3-16 AJAX支持之@RequestBody
- mybatis
- 1. mybatis第一天
- 1. 为什么使用mybatis
- 2. 下载地址
- 3. hello
- 4. mybatis三种开发模式
- 5. 全局配属属性内容
- 6. DTD设置
- 7. Mapper中的CRUD
- 8. 8.mybatis使用主键自增
- 9. #{}中的参数处理
- 10. #{}与${}区别
- 11. 集合数据的查询
- 12 动态sql
- 12.1 if
- 12.2 choose, when, otherwise
- 12.3 trim, where, set
- 12.4 foreach
- 代码位置
- 2. mybatis第二天
- 1.封装map类型的数据
- 2. resultMap自定义封装规则
- 0代码位置
- 3. mybatis缓存机制
- ssm整合
- 1.maven
- 2.ssm基础环境搭建
- 2-1 引入项目依赖的jar包
- 2-2 引入bootstrap,jquery
- 2-3 创建项目包结构
- 2-4 编写web.xml配置文件
- 2-5 编写sping,springmvc,mybatis配置文件
- 2-6 逆向工程mbg.xml
- shiro安全框架
- 1.shiro简介
- 易购Buy商城
- 第一天
- 1.课程计划
- 2.电商行业背景
- 3.易购Buy介绍
- 4.易购Buy架构
- 5.工程搭建
- 6.工程启动和测试
- 7.ssm框架整合
- 8.整合测试
- 9.svn
- 9.1 svn服务端
- 9.2 svn客户端
- 第二天
- 1.SOA架构分析
- 2.dubbo使用方法
- 3.注册中心
- 4.工程改造
- 5.easyUI
- maven
- 1.maven介绍
- 2.idea配置maven和服务器
- 3.创建web工程
- 4.分模块构建工程
- 5. 代码位置
- 6. nexus
- Luence搜索
- 1.了解搜索技术
- 2.Lucene的基本使用
- solr
- SolrCloud
