Spring Boot整合thymeleaf
来源:互联网 发布:centos7 网络配置 编辑:程序博客网 时间:2024/04/28 02:14
今天继续学习了Spring boot的一些东西,然后我就整合了一个Thymeleaf 这个模板中间经历了非常多的困难 现在记录下来我的惨痛经历
First Blood
刚开始我直接建了一个普通的工程,我闲建Maven工程太费劲了,然后我就把我的jar包直接导入进去了,这就导致了我的第一个问题,无法找到*.HTML的文件。
把我的pom.xml放了上来 仅供参考
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.2.RELEASE</version> <relativePath /> <!-- lookup parent from repository --> </parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <!-- mysql连接 --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency> <!-- mybatis --> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>1.1.1</version> </dependency> <!-- https://mvnrepository.com/artifact/com.alibaba/fastjson --> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.7</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <dependency> <groupId>net.sourceforge.nekohtml</groupId> <artifactId>nekohtml</artifactId> <version>1.9.22</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build>
Double Kill
Spring Boot的配置文件报错 ,天呐
//* 就是你自己的东西了
server.port=8011spring.datasource.url=jdbc:mysql://****?characterEncoding=utf8&useSSL=truespring.datasource.username=****spring.datasource.password=****spring.datasource.driver-class-name=com.mysql.jdbc.Drivermybatis.mapperLocations=classpath:com/****/MapperXML/*.xmlspring.thymeleaf.content-type=text/html spring.thymeleaf.cache=false spring.thymeleaf.mode =LEGACYHTML5
其实很简单的东西 然后在 resource的文件夹里建一个Hello World.html,
里面放上
<!DOCTYPE HTML><html xmlns:th="http://www.thymeleaf.org"><head> <title>hello</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body><!--/*@thymesVar id="name" type="java.lang.String"*/--><p th:text="'Hello!, ' + ${name} + '!'" >3333</p></body></html></html>
Controller 为
.
@Controllerpublic class HelloController { @RequestMapping(value = "hello", method = RequestMethod.GET) public String hello(Model model) { model.addAttribute("name", "Dear"); return "hello"; }}
加油
阅读全文
0 0
- spring boot 整合 thymeleaf
- Spring Boot整合thymeleaf
- spring-boot--整合thymeleaf模板
- spring-boot--整合thymeleaf模板
- Spring Boot(4)整合thymeleaf
- Spring Boot 整合 Thymeleaf 完整 Web 案例
- Spring Boot 整合 Thymeleaf 完整 Web 案例
- Spring Boot整合Thymeleaf模板引擎
- Spring boot项目整合thymeleaf和shiro
- spring boot 学习(二)spring boot 框架整合 thymeleaf
- spring boot 学习(二)spring boot 框架整合 thymeleaf
- spring boot 使用thymeleaf 和shiro标签整合
- (五)Spring Boot配置静态资源访问,整合Thymeleaf模板
- [spring-boot] thymeleaf 热交换
- Spring Boot + Gradle + Thymeleaf
- spring boot vue Thymeleaf
- spring boot thymeleaf 用法
- Spring Boot使用Thymeleaf
- 银行卡格式化(每四位空格,删除添加,更变等)
- 线程池参数解析
- java 网络编程三要素之协议(TCP协议):
- Informix-4gl数据库的dbexport导出与dbimport还原
- 理解linux的硬链接与软链接
- Spring Boot整合thymeleaf
- Error in module : Declaration of class TFhygl is missing or incorrect解决办法
- 1.1 发布webservice 服务
- 全选功能的实现(兼容ie8,可以部分禁用)
- 基数估计算法(一):Flajolet-Martin算法
- ThreadLocal
- Xss、Sql、Emoji过滤器+SpringMVC JSON过滤
- 第一章 计算机性能评价
- MySQL 日期类型及默认设置