![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
springboot学习笔记
小猿不秃头
这个作者很懒,什么都没留下…
展开
-
springboot部署在tomcat中需要注意的地方
如果想要将springboot的web项目打包部署进Tomcat的webapps目录下,单纯更改packaging为war,补全web.xml文件打包后将war包放进去是不行的,需要在springboot的启动类中做以下的代码更改:要此类要继承SpringbootServletInitializer类,并重写他的configure方法,具体代码如下:import org.sprin原创 2018-01-13 21:06:20 · 2753 阅读 · 0 评论 -
springboot中thymeleaf页面处理
ps:所有页面语句都要闭合一:需要显示原本内容不做转义操作如果后端传的值中有html标签如:red">红色如果不加u直接使用th:text,则thymeleaf模板会自动将此html标签转义编程text文本,加了th:utext则会让此html标签生效。二:资源的定位thymeleaf页面中进行资源的定位使用“@{路径名}”三:对象的输出其中关于“${属性}”和“*原创 2018-01-13 22:57:07 · 1045 阅读 · 0 评论 -
Spring3.2新注解@ControllerAdvice
Spring3.2新注解@ControllerAdvice@ControllerAdvice,是spring3.2提供的新注解,从名字上可以看出大体意思是控制器增强。让我们先看看@ControllerAdvice的实现: Java代码 @Target(ElementType.TYPE) @Retention(RetentionPoli转载 2018-01-15 15:51:10 · 383 阅读 · 0 评论 -
springboot的错误页面配置
springboot的错误页面配置可以在代码中配置一个错误页面的配置类,代码如下:package com.fyq.bootDeveloper.config;import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;import org.springframewor原创 2018-01-13 17:13:52 · 5315 阅读 · 1 评论 -
Gson使用方法,json字段转List,转对象
Gson 是 Google 提供的用来在 Java 对象和 JSON 数据之间进行映射的 Java 类库。可以将一个 JSON 字符串转成一个 Java 对象,或者反过来。对象转为字符串String ps =gson.toJson(person);字符串转为对象Person person =gson.fromJson(json, Person.class转载 2018-01-18 00:26:03 · 2238 阅读 · 0 评论 -
Spring Boot 集成MyBatis
Spring Boot 集成MyBatis在集成MyBatis前,我们先配置一个druid数据源。Spring Boot 系列Spring Boot 入门Spring Boot 属性配置和使用Spring Boot 集成MyBatisSpring Boot 静态资源处理Spring Boot - 配置排序依赖技巧Spring Bo转载 2018-01-14 16:37:03 · 1081 阅读 · 1 评论 -
SpringMVC BindingResult验证框架Validation用法
使用注解一、准备校验时使用的JARvalidation-api-1.0.0.GA.jar:JDK的接口;hibernate-validator-4.2.0.Final.jar是对上述接口的实现;log4j、slf4j、slf4j-log4j 二、编写需要校验的bean@NotNull(message="名字不能为空")private String userName;@Max(value=120转载 2018-01-17 23:17:19 · 569 阅读 · 0 评论 -
springboot使用redis缓存
springboot比ssm配置redis要简单方便很多,下面进入配置步骤首先在pom.xml文件中引入依赖:spring-boot-starter-data-redis然后在application.yml文件中配置redis的IP地址和端口号,如果有密码还得配置密码如图:然后在springboot的启动类上添加@EnableCaching注解,你的所有类都得在springboot原创 2018-01-30 00:21:51 · 1657 阅读 · 0 评论