当前位置: 首页 > news >正文

dede网站搬家更换空间重新安装永州本地网站建设

dede网站搬家更换空间重新安装,永州本地网站建设,域名管理,网站建设课程设计要求SpringIOC 作用: 实现了层与层之间对象的逻辑性的解耦.IOC将耦合性非常高的对象进行解耦. SpringIOC创建对象的三种方式 1.通过构造器方式 ①无参数构造器(创建一个没有初始化数据的对象) ②有参 数构造器(创建一个带有初始化数据的对象) Applicationcontext.xml ?x…SpringIOC 作用: 实现了层与层之间对象的逻辑性的解耦.IOC将耦合性非常高的对象进行解耦. SpringIOC创建对象的三种方式 1.通过构造器方式 ①无参数构造器(创建一个没有初始化数据的对象) ②有参 数构造器(创建一个带有初始化数据的对象) Applicationcontext.xml ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd!--创建student的bean对象--!--构造器方式--!--无参构造器 特点Spring容器默认使用无参构造方式创建对象使用在配置文件中直接使用bean标签配置即可无需过多声明--bean idstu classcom.bjsxt.pojo.Student/bean!--有参数的构造器特点Spring容器对根据配置调用的有参构造器创建一个带有初始化数据的对象使用constructor-arg使用bean的字标签来声明调用的构造器的形参的个数一个字标签表示一个参数属性index参数的下标type参数的类型全限定路径name参数的形参名value参数要给的值--bean idstu2 classcom.bjsxt.pojo.Studentconstructor-arg index0 typejava.lang.Integer namesid value1/constructor-argconstructor-arg index1 typejava.lang.String namesname value张三/constructor-arg/bean/beans TestObject.java package com.java.controller;import com.java.pojo.Student; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext;public class testStu {public static void main(String[] args) {//创建容器对象ApplicationContext ac new ClassPathXmlApplicationContext(applicationcontext.xml);//获取容器中的对象//无参构造器方式Student student (Student) ac.getBean(stu);System.out.println(无参构造student);//有参构造器Student student1 (Student) ac.getBean(stu2);System.out.println(有参构造student1);} } 2.通过属性注入(get/set) ApplicationContext.xml ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd!--创建student的bean对象--!--属性注入方式特点相当于创建一个空对象然后使用set方法赋值使用property在bean标签下使用子标签property表示调用set方法给某个属性赋值属性name要赋值的属性名value值--bean idstu3 classcom.bjsxt.pojo.Studentproperty namesid value2/propertyproperty namesname value李四/property/bean /beans TestObject.java package com.java.controller;import com.java.pojo.Student; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext;public class testStu {public static void main(String[] args) {//创建容器对象ApplicationContext ac new ClassPathXmlApplicationContext(applicationcontext.xml);//获取容器中的对象//属性注入方式Student student (Student) ac.getBean(stu3);System.out.println(属性注入方式student);} } 3.通过工厂模式 ①动态工厂模式 ②静态工厂模式 applicationcontext.xml ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd!--创建student的bean对象--!--工厂设计模式--!--动态工厂--bean idfactory classcom.bjsxt.pojo.StudentFactory/bean!--生产Student对象--bean idstu4 factory-beanfactory factory-methodnewIntance/bean!--静态工厂--!--可以理解为静态方法直接用类名调用--bean idstu5 classcom.bjsxt.pojo.StudentFactory2 factory-methodnewIntance/bean /beans TestObject.java package com.java.controller;import com.java.pojo.Student; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext;public class testStu {public static void main(String[] args) {//创建容器对象ApplicationContext ac new ClassPathXmlApplicationContext(applicationcontext.xml);//获取容器中的对象//工厂设计模式 //动态工厂Student student (Student) ac.getBean(stu4);System.out.println(动态工厂student);//静态工厂Student student1 (Student) ac.getBean(stu5);System.out.println(静态工厂student1);} } IOC的依赖注入DI 依赖责任链: 对象之间项目依赖形成的一条链式依赖关系. D dnew D(); C cnew C(d) B bnew B©; A anew A(b); A—B----C----D 解决: 让Spring容器根据对象之间的依赖关系,将依赖责任连上的所有的对象全部配置为Bean对象.并且根据依赖关系完成对象之间的组装.将组装好的对象返回给用户使用. 概念: DI:依赖注入,就是Spring容器根据对象之间的依赖关系完成对象的创建以及组装的过程. applicationcontext.xml ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd!-- DI依赖的使用流程 ①将依赖责任链上的所有的对象都配置为bean ②根据依赖关系完成对象之间的组装配置通过构造器方式:i.必须在类中声明对应的构造器ii.在bean标签下使用constructor-arg子标签完成以来注入使用constructor-arg的属性ref,ref的值为要注入的bean的ID通过set方法方式i.必须在类中声明引用属性对应的set方法ii.在bean标签下使用property子标签完成以来注入在property子标签中使用ref属性,属性值为要被注入的bean的ID --!--配置学生bean对象--bean idstu classcom.bjsxt.pojo.Student!--构造器方式--constructor-arg index0 nameteacher typecom.bjsxt.pojo.Teacher reftea /constructor-arg!--set方式--property nameteacher reftea/propertyproperty namesname value张三/propertyproperty namesid value1/property/beanbean idtea classcom.bjsxt.pojo.Teacherproperty nametid value2/propertyproperty nametname value刘老师/property/bean /beans TestIocDI.java package com.java.contorller;import com.java.pojo.Student; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext;public class TestIocDI {public static void main(String[] args) {//获取spring对象ApplicationContext ac new ClassPathXmlApplicationContext(applicationcontext.xml);Student stu (Student) ac.getBean(stu);System.out.println(stu);stu.testStu();} }
http://wiki.neutronadmin.com/news/51818/

相关文章:

  • 响应式网站项目徐州网络推广
  • 山西网站开发公司重庆网站建设优化
  • 广西建设厅网站首页微网站 百度地图
  • 山河集团建设有限公司网站深圳企业排行
  • 自己的电脑做网站空间视屏赣州吧百度贴吧
  • 网站建设对客户的优势cms建站系统免费
  • dede旅游网站wordpress浮动播放器
  • 做网站银川seo外包公司多少钱
  • 网站建设参数河北建设厅注册中心网站首页
  • 做营利网站的风险php网站开发职位
  • php婚庆网站微信网站系统
  • 浅谈高校门户网站建设的规范标准一个域名权重3如果做网站的话权重会降为0吗
  • 西双版纳傣族自治州天气预报15天关键词优化推广排名软件
  • 海南省建设局网站搜索qq推广效果
  • 外贸网站如何做外链云龙主机 wordpress
  • 天津网站建设制作方案云服务器 部署网站
  • 建设局网站首页wordpress新建子域名多站点
  • 中山品牌网站建设报价网络安全十大公司
  • 宣讲家网站两学一做客户关系管理系统的功能
  • 用户体验做的好的网站市场管理监督局是干什么的
  • 杭州网站建设哪家比较好郴州新网手机版
  • 网站开发包罗湖网站制作多少钱
  • 郑州大型网站天津网站建设网络
  • 免费推广网站2023windows优化大师软件介绍
  • 威海 网站建设太仓网站建设教程
  • 自己做网站是不是需要写代码最好用的磁力搜索神器
  • 都匀市建设局网站如何将网站地图提交给百度
  • 外贸网站如何优化云计算存储网站建设安全
  • 如何推广好一个产品关键词优化建议
  • 汕头网站安全开发系统怎么给公司做简单网站