自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(22)
  • 收藏
  • 关注

原创 Interceptor

拦截器的使用@Componentpublic class MyInterceptor implements HandlerInterceptor { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { HttpSession session = request.ge

2021-11-11 00:11:08 81

原创 springmvc-JSON

一·导入Jackson的依赖 <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.13.0</version> </dependency>二·封装

2021-11-09 22:07:23 81

原创 重定向转发,接受参数以及乱码问题解决

一·重定向和转发:添加视图解析器,return的字符串,经过解析,跳转视图默认是转发。@RequestMapping("/h1") public String test(Model model){ model.addAttribute("msg","h1"); //默认是转发 return "hello"; } 实现重定向:在字符串前面加上redirect即可: @RequestMapping("/h2")...

2021-11-06 16:21:15 449

原创 Restful风格

原始在前端传参的时候,如果通过get方法会有以下显示://原始的传参方式:/add?a=1&b=2restful风格就是将参数也作为url地址写在后面。/add/1/2具体实现:对方法形参加上@PathVariable注解,地址映射中用{a}就可以取出。@RequestMapping(value = "/add/{a}/{b}",method = RequestMethod.DELETE) public String test(@PathVariable.

2021-11-06 16:06:04 54

原创 springMVC注解开发

一·添加注解和mvc的约束<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:mvc="http://www.springframework.org

2021-11-05 20:48:59 84

原创 springMVC的初识

一·导入所需要的jar包 <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.13</version> <scope>test</scope> </dependenc

2021-11-05 20:40:42 62

原创 spring声明式事务

一·导入jar包:spring事务管理需要jar包<dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>5.3.11</version> </dependency>二·开启

2021-11-04 19:30:03 106

原创 spring整合Mybatis

一·导入需要的jar包<dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.13</version> <scope>test</scope> </dependency>

2021-11-03 22:11:42 79

原创 spring-AOP

一·AOP面向切面编程 在软件业,AOP为Aspect Oriented Programming的缩写,意为:面向切面编程,通过预编译方式和运行期间动态代理实现程序功能的统一维护的一种技术。AOP是OOP的延续,是软件开发中的一个热点,也是Spring框架中的一个重要内容,是函数式编程的一种衍生范型。利用AOP可以对业务逻辑的各个部分进行隔离,从而使得业务逻辑各部分之间的耦合度降低,提高程序的可重用性,同时提高了开发的效率。底层是动态代理,意思就是横向开发,在一般的纵向开发中,为某些方法进行横向...

2021-11-02 17:34:51 40

原创 spring代理模式

一·静态代理模式房东要出租房子,中介代理房东,并有额外的操作,他们共同实现一个Rent接口。Rent接口:public interface Rent { void rent();}Host类:public class Host implements Rent{ @Override public void rent() { System.out.println("房东要租房子"); }}Proxy代理类:public cla

2021-11-02 16:57:29 39

原创 javaConfig配置bean

1.用@ComponentScan("com.he.pojo")去扫描@Configuration@ComponentScan("com.he.pojo")public class HeConfig {}@Component("b")public class Book { @Value("java") private String name; @Value("800") private int size; @Override pub..

2021-11-01 18:43:43 618

原创 spring自动装配以及注解的使用

一·使用xml自动装配: <bean id="cat" class="com.he.pojo.Cat"/> <bean id="dog" class="com.he.pojo.Dog"/><!--显示装配--> <bean id="people" class="com.he.pojo.People"> <property name="cat" ref="cat"/> <property

2021-11-01 13:58:47 89

原创 spring依赖注入

一·spring的简单配置可以用alias标签配置别名,在外部可以通过别名获取相同的对象。<bean id="hello" class="com.he.pojo.Hello"> <property name="str" value="spring"></property> </bean> <alias name="hello" alias="hello6"></alias>也可以直接使用be

2021-10-31 14:15:33 153

原创 spring之创建对象

一·IOC(控制反转) spring 容器帮我们查找及注入依赖对象,对象只是被动的接受依赖对象,一句话,所有的对象都可以放在一个spring容器里,由spring容器来创建对象,而代码中只需要接受对象,spring容器可以为一个xml文件,在里面配置类,并可以在外面获取,控制权来到了spring容器这里。二·导入jar包从maven仓库中寻找依赖: <!-- https://mvnrepository.com/artifact/org.springfra...

2021-10-30 20:54:16 377

原创 动态SQL

一·简介 动态 SQL 是 MyBatis 的强大特性之一。如果你使用过 JDBC 或其它类似的框架,你应该能理解根据不同条件拼接 SQL 语句有多痛苦,例如拼接时要确保不能忘记添加必要的空格,还要注意去掉列表最后一个列名的逗号。利用动态 SQL,可以彻底摆脱这种痛苦。二·环境搭建建表:CREATE TABLE `blog`(`id` VARCHAR(50) NOT NULL COMMENT '博客id',`title` VARCHAR(100) NOT NULL COMMENT..

2021-10-29 21:28:08 91

原创 MyBatis结果集映射之一对多,多对一

一·复杂查询环境搭建在数据库库中建学生表和老师表,建造一个老师有多个学生的一对多关系:drop table if exists teacher;create table teacher( id int primary key , name varchar(20))engine = innodb charset = utf8;drop table if exists student;create table student( id int primary key ,

2021-10-28 22:58:05 226

原创 MyBatis使用注解开发

一·@Select,@Insert,@Delete,@Update注解不再需要userMapper的xml映射,直接在接口中的方法上加上注解即可,但还需要在核心配置文件中配置mapper,只能用类class导入。 <mapper class="com.he.dao.userDao.UserMapper"></mapper>接口方法:增删改查:public interface UserMapper { @Select("select * from us

2021-10-27 23:31:48 72

原创 MyBatis分页实现

一·使用limit语句传递一个参数map,起始页和pageSize<!-- 分页查询 --> <select id="getUserByLimit" parameterType="map" resultMap="userMap"> select * from mybatis.user limit #{startIndex},#{pageSize} </select>测试:// 分页 @Test

2021-10-27 22:28:19 87

原创 MyBaitis日志

一·日志的配置在核心配置文件中,一般是mybatis-config.xml,中使用setting进行配置:<settings> <setting name="logImpl" value="LOG4J"/> </settings>SLF4J | LOG4J | LOG4J2 | JDK_LOGGING | COMMONS_LOGGING | STDOUT_LOGGING | NO_LOGGING 以上都是日志,STDOUT为标准日志输

2021-10-27 00:15:01 55

原创 MyBatis配置优化

一·属性优化可以建立一个db.properties,然后从外部引入文件db.properties:driver=com.mysql.jdbc.Driverurl=jdbc:mysql://localhost:3306/mybatis?useSSL=false&useUnicode=true&characterEncoding=UTF8username=rootpassword=123456从外部引入:<properties resource="db.pr.

2021-10-26 16:51:33 67

原创 MyBatis增删改查

默认环境已经配置好注意:resultType:返回值类型,如果为实体类,则需要写具体位置,如com.he.pojo.UserparameterType为传入参数类型,通过#{ }可以获取。#{ }可以直接填类的字段#{username},#{pwd}等也可以用map传参,#{ }填的是map的key值一.增1.UserMapper接口里面添加方法int insertUser(User user);2.在Mapper.xml中配置映射。<insert id="

2021-10-24 21:52:00 1437

原创 MyBatis的配置以及第一个MyBatis程序

一·MyBatis简介 MyBatis 是一款优秀的持久层框架,它支持自定义 SQL、存储过程以及高级映射。MyBatis 免除了几乎所有的 JDBC 代码以及设置参数和获取结果集的工作。MyBatis 可以通过简单的 XML 或注解来配置和映射原始类型、接口和 Java POJO(Plain Old Java Objects,普通老式 Java 对象)为数据库中的记录。二.MyBatis的配置1.先在SQLyog中建立数据库,建立mybatis数据库,建一个表,用于测试。CREAT..

2021-10-24 15:45:06 1522

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除