- 1、本文档共18页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Spring 章 J2EE概述 JavaEE教学课件PPT
Spring 江西农业大学软件学院北京实习基地 依赖注入(Dependency Injection) 在运行时由容器将依赖关系注入到组件中 一个简单例子—接口 public interface Washable { public void wash(); } 一个简单的例子—类1 一个简单的例子—类1(代码) public class Cloth implements Washable { public void wash() { System.out.println(洗衣服); } } 一个简单的例子—类2 一个简单的例子—类2(代码) public class Car implements Washable { public void wash() { System.out.println(洗汽车); } } 一个简单的例子—配置文件 ?xml version=1.0 encoding=UTF-8? beans xmlns=/schema/beans xmlns:xsi=/2001/XMLSchema-instance xsi:schemaLocation=/schema/beans /schema/beans/spring-beans-2.5.xsd bean id=w class=Cloth/bean /beans 一个简单的例子—主程序 import org.springframework.context.ApplicationContext; import org.springframework.context.support.FileSystemXmlApplicationContext; public class T { public static void main(String[] args) { ApplicationContext ctx = new FileSystemXmlApplicationContext(applicationContext.xml); Washable w = (Washable)ctx.getBean(w); w.wash(); } } 添加Spring的jar文件 org.springframework.web-3.0.1.RELEASE-A.jar org.springframework.core-3.0.1.RELEASE-A.jar org.springframework.beans-3.0.1.RELEASE-A.jar org.springframework.context-3.0.1.RELEASE-A.jar。 org.springframework.context.support-3.0.1.RELEASE-A.jar org.springframework.asm-3.0.1.RELEASE-A.jar org.springframework.expression-3.0.1.RELEASE-A.jar 添加Struts2中和Spring有关的jar文件 struts2-spring-plugin-.jar 一个例子— web.xml listener listener-calssorg.sringframework.web.context.ContextLoaderListener/listener-class /listener 一个例子—接口 一个例子—接口(代码) package service; import bean.Team; import java.util.Collection; public interface TeamService { public void addTeam(Team team) throws Exception; public CollectionTeam allTeams() throws Exception; public Team getTeamById(int id) throws Exception; public void modifyTeam(Team team) throws Exception; public void deleteTeam(Team team) throws Exception; } 一个例子—action public class AddTeam { private Team team; private TeamService teamService; …… public String execute() { try { teamServic
您可能关注的文档
- note 003 Simple Adjustment Financial account 财务会计 教学课件.ppt
- NOKIA交换机维护资料 MSS&MGW&HLR日常维护交流.ppt
- NOTE 5 Financial Accounting of Sole Trader Financial account 财务会计 教学课件.ppt
- note 005 Financial Accounting of Sole Trader Financial account 财务会计 教学课件.ppt
- NounAdjectives 德语初级适用 教学课件.ppt
- NOTE3 Simple Adjustment Financial account 财务会计 教学课件.ppt
- NOC服务助理及外事礼仪知识.ppt
- NPC and CPPCC Sessions 2012 两会PPT 英文版教学课件.ppt
- N阱硅栅CMOS工艺流程 电子器件与工艺课件.doc
- NSDI2.0讲课记录 WebGIS课件.pdf
- 甘肃省XB师范大学附属中学2025届高三上学期一模诊断考试地理答案.doc
- 甘肃省XB师范大学附属中学2025届高三上学期一模诊断政治含解析.doc
- 安徽省皖江名校2024-2025学年高一上学期12月联考英语无答案.doc
- 2025年1月八省联考高考综合改革适应性测高三化学陕西山西宁夏青海卷无答案.doc
- 2025年1月八省联考高考综合改革适应性测高三化学四川卷无答案.doc
- 2025年1月八省联考高考综合改革适应性测高三政治陕西山西宁夏青海卷无答案.doc
- 2025年1月内蒙古自治区普通高等学校招生考试适应性测试(八省联考)历史无答案.doc
- 2025年1月内蒙古自治区普通高等学校招生考试适应性测试(八省联考)历史含解析.doc
- 2025年1月四川省普通高等学校招生考试适应性测试(八省联考)历史含解析.doc
- 2025年1月四川省普通高等学校招生考试适应性测试(八省联考)政治无答案.doc
最近下载
- 【高分阅读】五年级阅读理解——分析字词句段的含义或作用(含答案)部编版.pdf VIP
- 《我们大家跳起来》(课件)人音版(2012)音乐四年级下册.pptx
- 川教版九年级上册生命生态与安全教案.doc
- 16-1 第1课时 二次根式的概念 课件.pptx VIP
- 工程振动与测试技术课件-第十章非线性振动.ppt VIP
- 江苏省家庭养老床位建设和服务协议.docx
- 施乐5955维修手册.pdf
- 2025年流感预防、治疗及护理理论知识考核试题及答案 .pdf VIP
- 环境污染修复技术与案例-全套PPT课件.pptx
- 实用阶梯英语—写作教程unit 8 Essay & Essay Structure.ppt VIP
文档评论(0)