03 2021 档案

摘要:返回字符串 返回字符串相当于返回视图名称,该视图名称经过视图解析器得到视图路径 @RequestMapping("/testString") public String testString() { System.out.println("testString()执行"); return "succ 阅读全文
posted @ 2021-03-31 17:18 ttpfx 阅读(59) 评论(0) 推荐(0) 编辑
摘要:RequestParam 作用:将请求参数与方法形参绑定 属性: value:指定请求参数名称,可与方法形参不一致 required: 是否必传,默认为true RequestBody 作用:获取请求体 属性: required: 是否必传,默认为true PathVariable 作用: 获取UR 阅读全文
posted @ 2021-03-30 16:07 ttpfx 阅读(371) 评论(0) 推荐(0) 编辑
摘要:绑定基本类型和String 请求参数名称与方法形参名称一致即可 @RequestMapping(path = "/test1") public String test1(String username, String password) { System.out.printf("username=% 阅读全文
posted @ 2021-03-30 14:56 ttpfx 阅读(72) 评论(0) 推荐(0) 编辑
摘要:作用 用与建立URL与处理请求方法之间的对应关系 属性 value/path: 二者含义相同,指定请求URL method:数组,指定允许访问的请求方式,不设置则不限制。使用不允许的请求方式,HTTP状态码返回405 params:数组,限制必须传入的请求参数。缺少参数时,HTTP状态码返回400 阅读全文
posted @ 2021-03-30 14:38 ttpfx 阅读(77) 评论(0) 推荐(0) 编辑
摘要:Maven依赖 <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> <scope>provided</scope> </dependency 阅读全文
posted @ 2021-03-30 09:28 ttpfx 阅读(38) 评论(0) 推荐(0) 编辑
摘要:AOP术语 通知 Advice : 切面的工作。通知定义了切面是什么,以及何时使用。 前置通知 Before 后置通知 After : 无论是否抛出异常都会调用 返回通知 After-returing :方法正常执行无异常之后调用 异常通知 After-throwing : 在目标方法抛出异常后调用 阅读全文
posted @ 2021-03-25 17:40 ttpfx 阅读(55) 评论(0) 推荐(0) 编辑
摘要:安装spring-test和junit依赖,其中junit依赖的版本不低于4.12 <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>5.3.4</ver 阅读全文
posted @ 2021-03-25 17:39 ttpfx 阅读(53) 评论(0) 推荐(0) 编辑
摘要:配置自动扫描的包 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema 阅读全文
posted @ 2021-03-25 17:38 ttpfx 阅读(26) 评论(0) 推荐(0) 编辑
摘要:通过构造函数注入 <bean id="accountDao" class="com.ttpfx.dao.impl.AccountDaoImpl"/> <bean id="accountService" class="com.ttpfx.service.impl.AccountServiceImpl" 阅读全文
posted @ 2021-03-17 18:28 ttpfx 阅读(49) 评论(0) 推荐(0) 编辑
摘要:Maven导入Spring依赖 <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>5.3.3</version> </dependency> Spr 阅读全文
posted @ 2021-03-17 12:26 ttpfx 阅读(54) 评论(0) 推荐(0) 编辑
摘要:简单CRUD package com.ttpfx.dao; import com.ttpfx.domain.User; import org.apache.ibatis.annotations.*; import java.util.List; public interface UserDao { 阅读全文
posted @ 2021-03-10 16:14 ttpfx 阅读(34) 评论(0) 推荐(0) 编辑
摘要:延迟加载 延迟加载是指关联对象的按需加载。把对多个表的一次连表查询,分解为对多个单表的多次查询。默认只查询主表的数据,在使用查询结果对象时,才去对关联表进行查询。 优点:提高数据库性能,单表查询效率高于连表查询 缺点:增加查询次数? 全局设置 <settings> <setting name="la 阅读全文
posted @ 2021-03-10 09:53 ttpfx 阅读(45) 评论(0) 推荐(0) 编辑
摘要:一对一 一个账户对应一个用户: 账户实体: public class Account { private Integer id; private Double money; private User user; } 用户实体: public class User { private Integer 阅读全文
posted @ 2021-03-09 17:43 ttpfx 阅读(94) 评论(0) 推荐(0) 编辑
摘要:if 和 where public interface UserDao { List<User> getUserListByCondition(User user); } <select id="getUserListByCondition" parameterType="User" resultT 阅读全文
posted @ 2021-03-09 11:53 ttpfx 阅读(42) 评论(0) 推荐(0) 编辑
摘要:属性(properties) 通过properties的子元素设置配置项: <properties> <property name="driver" value="com.mysql.cj.jdbc.Driver"/> <property name="url" value="jdbc:mysql:/ 阅读全文
posted @ 2021-03-09 10:00 ttpfx 阅读(89) 评论(0) 推荐(0) 编辑
摘要:第一种解决方法:在sql中使用别名 <select id="getRoleList" resultType="com.ttpfx.domain.Role"> select ID as id, ROLE_NAME as name, ROLE_DESC as description from role; 阅读全文
posted @ 2021-03-08 11:21 ttpfx 阅读(73) 评论(0) 推荐(0) 编辑
摘要:Dao接口 package com.ttpfx.dao; import com.ttpfx.domain.User; import java.util.List; public interface UserDao { List<User> getAll(); List<User> getUserLi 阅读全文
posted @ 2021-03-04 17:09 ttpfx 阅读(37) 评论(0) 推荐(0) 编辑
摘要:1.创建空的Java工程,安装MyBatis依赖 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/X 阅读全文
posted @ 2021-03-04 14:27 ttpfx 阅读(75) 评论(0) 推荐(0) 编辑