springMVC搭建
springMVC搭建
1.Spring特点:
方便耦合,简化开发,提升性能
AOP面向切面的编程
声明式事务支持
方便程序的调试
方便集成各大优秀的框架
Java源代码学习的典范
2.Java的面向对象,继承、封装和多态(IOC)
Java的本质是什么:面向对象
对象是怎么创建的:new
对象的职责:调用方法和属性(给属性赋值、调用方法、使用)
3.快速搭建一个springMVC框架,实现登录
案例:SpringMVC+Hibernate实现HelloWorld程序
下载spring
4.spring体系结构
----------------------------------------------------------
JDBC ORM MVC
OXM JMS Project 测试框架
事务管理 Webservice
----------------------------------------------------------
AOP
(Java动态代理、CGLIB动态代理、AOP联盟)
在执行某个方法之前、过程、之后、异常、日志处理、事务管理、定时任务通知
-----------------------------------------------------------
IOC(Java本质)
5.JavaBean的作用
a.为什么要生成getter和setter方法(就是为了给属性赋值)
私有属性无法赋值
b.extends的作用
代码的复用和维护
6.IOC是Spring核心业务模块,它是将类与类之间的依赖从代码中脱离出来,
IOC容器(BeanFactory、ApplicationContext),这个容器负责类与类之间
对象创建,拼接,管理(存储),获取
怎么给属性赋值呢
set注入、构造函数注入、反射注入
7.搭建一个框架难就难在
你是否了解继承的,实现接口的定义
8.导入的包讲解
jar包下载地址 http://maven.springframework.org/release/org/springframework/spring/
spring-core-4.1.5.RELEASE.jar 核心jar
spring-beans-4.1.5.RELEASE.jar BeanFactory 工厂IOC
spring-context-4.1.5.RELEASE.jar
spring-context-support-4.1.5.RELEASE.jar
spring-expression-4.1.5.RELEASE.jar 表达式语言
spring-jdbc-4.1.5.RELEASE.jar 数据库连接处理
spring-test-4.1.5.RELEASE.jar 测试
spring-web-4.1.5.RELEASE.jar springMVC
spring-webmvc-4.1.5.RELEASE.jar springMVC
依赖包
在apache下common都可以下载到
http://commons.apache.org/
commons-dbcp-1.2.1.jar 数据库连接池包
commons-lang3-3.1.jar 语言包
commons-logging-1.1.3.jar 日志包,框架都使用了日志管理
数据库的驱动包
mysql-connector-java-3.1.13-bin.jar
9.搭建框架的结构
springMVC
src
com.rui
dao (查询数据)
web (视图层)
model (模型层)
service (业务处理层)
core 核心层(拦截器)
util 工具类
applicationContext.xml spring核心配置文件
log4j.properties 日志文件
webroot
js
images
css
web-inf
pages
user.jsp
web.xml
10.搭框架的路线
applicationContext.xml
<?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"
xmlns:p="http://www.springframework.org/schema/p"
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
">
<!-- @Compoment这类型注解的类都是需要被扫描 说白就是:让Spring的ApplicationContext去加载和初始化所有加了注解的类,给实例化
@Repository:数据层的dao @Service:service就是service @Controller:web比如:action和springmvc-controller类 -->
<!-- 扫描文件所在dao包 -->
<context:component-scan base-package="com.rui.dao"></context:component-scan>
<context:component-scan base-package="com.rui.service"></context:component-scan>
</beans>
11.测试连接数据库
BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName("com.mysql.jdbc.Driver");
dataSource.setUrl("jdbc:mysql://localhost:3306/spring");
dataSource.setUsername("root");
dataSource.setPassword("root");
Connection connection = dataSource.getConnection();
System.out.println(connection);
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
<property name="url" value="jdbc:mysql://localhost:3306/spring"></property>
<property name="username" value="root"></property>
<property name="passowrd" value="root"></property>
</bean>
springMVC搭建的更多相关文章
- 使用SpringMVC搭建第一个项目
概述 使用SpringMVC搭建第一个项目,入门教程,分享给大家. 详细 代码下载:http://www.demodashi.com/demo/10596.html 一.概述 1.什么是Spring ...
- springMVC学习总结(一) --springMVC搭建
springMVC学习总结(一) --springMVC搭建 搭建项目 1.创建一个web项目,并在项目中的src文件夹下创建一个包com.myl.controller. 2.添加相应jar包 3.在 ...
- 初学springMVC搭建框架过程及碰到的问题
刚刚开始学spring框架,因为接了一个网站的项目,想用spring+springMVC+hibernate整合来实现它,现在写下搭建框架的过程及碰到的问题.希望给自己看到也能让大家看到不要踏坑. 一 ...
- SpringMVC搭建+实例
想做一点自己喜欢的东西,研究了一下springMVC,所以就自己搭建一个小demo,可供大家吐槽. 先建一个WEB工程,这个相信大家都会,这里不在多说. 去网上下载spring jar包,然后在WEB ...
- springMVC---业务处理流程图和最简单的springMvc搭建截图说明
一.springMVC业务处理流程图: 二.如何搭建springMvc框架 1.建立web工程 2.引入jar包 3.创建web.xml文件 4.创建springMvc-servlet.xml文件 5 ...
- eclipse+maven springMVC搭建
1.新建项目: 选择Maven Project 选择项目位置,这里我选择的是C:\Users\admin\workspace\practice 选择maven项目类型,这里选择webapp: 填写Gr ...
- 【JavaEE】Springmvc搭建方法及example
现在介绍SSH的文章很多,但是适合自己需求的却经常找不到,这些东西呢,会了之后总会感觉别人的程序哪里哪里别扭,会之前呢就感觉很混乱,而且SSH的官方文档,至少在我看来是“会者勉强能看.不会者一片迷茫” ...
- 三分钟学会用SpringMVC搭建最小系统(超详细)_转载
前言 做 Java Web 开发的你,一定听说过SpringMVC的大名,作为现在运用最广泛的Java框架,它到目前为止依然保持着强大的活力和广泛的用户群. 本文介绍如何用eclipse一步一步搭建S ...
- MyBatis整合Spring+SpringMVC搭建一个web项目(SSM框架)
本文讲解如何搭建一个SSM架构的web站点 [工具] IDEA.SqlYog.Maven [简述] 该项目由3个模块组成:dao(数据访问层).service(业务处理层).web(表现层) dao层 ...
随机推荐
- 【maven + hibernate(注解) +spring +springMVC】 使用maven搭建项目
研究,百度,查资料+好友帮助,使用MyEcplise2015工具,通过maven搭建hibernate+springMVC+spring的项目,数据库采用MySql5.5 不过使用的版本会在项目搭建过 ...
- POJ 2418 字典树
题目链接:http://poj.org/problem?id=2418 题意:给定一堆树的名字,现在问你每一棵树[无重复]的出现的百分比,并按树名的字典序输出 思路:最简单的就是用map来写,关于字典 ...
- 如何定义移动端字体Font-Family?
1.对于IOS 手机系统,默认中文字体是Heiti SC.默认英文字体是Helvetica.默认数字字体是HelveticaNeue.无微软雅黑字体: 2.对于Android 手机系统,默认中文字体是 ...
- 20145223《Java程序程序设计》第9周学习总结
20145223<Java程序设计>第9周学习总结 教材学习内容总结 第十六章:整合数据库 JDBC入门 1.JDBC简介: 2.JDBC主要分成两个部分,JDBC应用程序开发者接口和JD ...
- 20145223《Java程序程序设计》第7周学习总结
20145223 <Java程序设计>第7周学习总结 教材学习内容总结 ·时间的度量: (1)格林威治标准时间 (2)世界时 (3)国际原子时 (4)世界协调时间 (5)Unix时间 (6 ...
- javascript关键字和保留字
1 关键字breakcasecatchcontinuedefaultdeletedoelsefinallyforfunctionifininstanceofnewreturnswitchthisthr ...
- windows安装python问题
在安装python过程中,直接下一步,安装好了,配置环境变量的时候如果找不到安装路径在哪,打开开始菜单,在左边的程序栏找到: 这样就找到了,然后在系统变量中加入即可.如果找不到的话,以联想电脑为例一般 ...
- HDU5008 Boring String Problem(后缀数组 + 二分 + 线段树)
题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=5008 Description In this problem, you are given ...
- HDU5785 Interesting(Manacher + 延迟标记)
题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=5785 Description Alice get a string S. She think ...
- CF#335 Board Game
Board Game time limit per test 2.5 seconds memory limit per test 256 megabytes input standard input ...