默认不支持jsp
配置文件
server:
port: 8081
spring:
application:
name: Shiro2205 #服务的名字
#mybatis
datasource: # 配置连接池信息
type: com.alibaba.druid.pool.DruidDataSource
url: jdbc:mysql://localhost:3306/5biao?useUnicode=true&characterEncoding=utf-8
username: root
password: 111
driver-class-name: com.mysql.cj.jdbc.Driver
# druid:
# initial-size: 10 #连接池中连接的核心连接数量
#配 mvc视图
mvc:
view:
prefix: /
suffix: .jsp
mybatis:
#实体类所在的包
type-aliases-package: com.qf.shiro2205.pojo
#映射文件在哪
mapper-locations: classpath:mappers/*.xml
configuration:
#主键生成策略
use-generated-keys: true
#强制使用驼峰命名法
map-underscore-to-camel-case: true
Springboot项目模糊查询,只能查数字,查不到中文和英文,结果都为空
因为springboot项目配置文件没加编码字符集
Springboot dao包上面加@Mapper
第一种
第二种 在启动类上
为什么@Mapper扫描?
让mybatis扫描dao所在的包,找到接口,生成代理类,创建代理类的对象
为什么启动类要放在其他包的父级路径上
因为@ComponentScan如果没有指定,那么将从声明的这个注解的类所在的包开始,扫描包及子包.
更改日期格式DateTimeFormat和JsonFormat区别
@DateTimeFormat仅支持前端使用表单键值对的请求提交方式,不支持Json格式的请求提交方式
String和date之间转换
RequestParam和RequestBody和PathVariable区别
@RequestBody和@RequestParam区别
@RequestParam
用来处理请求头为Content-Type: application/x-www-form-urlencoded编码的内容。
Http协议中,默认传参类型就是application/x-www-form-urlencoded。
URL中拼接参数也会使用此类型传递。
@RequestBody
处理HttpEntity传递过来的数据,一般用来处理非Content-Type: application/x-www-form-urlencoded编码格式的数据。
我们前端传递的json对象一般都以此方式在后端接收。
PathVariable测试路径
RequestBody测试方法
RequestParam测试方法
@PathVariable测试方法 Emp/a/10
启动器starter
Springboot-Starter-web依赖已经包含了spring springmvc