SpringBoot 使用Thymeleaf解决静态页面跳转问题
1,首先在pom文件中引入模板引擎jar包
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
2,在application.properties中配置模板引擎
spring.thymeleaf.prefix=classpath:/templates/
3,在templates下建立login.html文件
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<title>Title</title>
</head>
<body>
<h1>1314314141</h1>
</body>
</html>
4,写controller
package com.example; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; /**
* Created by hzm on 2017/4/1.
*/
@Controller
public class HelloController { @RequestMapping("/test")
public String test(){
return "login";
}
}
5输入网址
http://localhost:8080/test
6页面会出现
1314314141
SpringBoot 使用Thymeleaf解决静态页面跳转问题的更多相关文章
- Spring Boot 静态页面跳转
本篇博客仅为自己提个醒:如何跳转页面而不麻烦控制器. 当我们创建 Spring Boot 项目时(勾选了 Thymeleaf 和 Web),目录结构会是如下: 其中图二是我创建了一个 h ...
- js实现静态页面跳转传参
最近有个项目: 存静态web服务,一个新闻页面列表出所有新闻摘要信息,然后通过点击新闻详情访问到该新闻的详情页面: 新闻展示的页面通过ajax请求接口获取到新闻的摘要信息,预计想通过id的方式访问到新 ...
- SpringBoot 利用freemaker生成静态页面
1. <!-- freemarker模板 --> <dependency> <groupId>org.springframework.boot</groupI ...
- Vue解决同一页面跳转页面不更新
问题分析:路由之间的切换,其实就是组件之间的切换,不是真正的页面切换.这也会导致一个问题,就是引用相同组件的时候,会导致该组件无法更新. 方案一:使用 watch 进行监听 watch: { /* = ...
- springboot整合thymeleaf——引用静态资源
原html src="/css/index.css" thymeleaf中,th:src="@{/css/index.css}"
- SpringBoot系列——Thymeleaf模板
前言 thymeleaf是springboot官方推荐使用的java模板引擎,在springboot的参考指南里的第28.1.10 Template Engines中介绍并推荐使用thymeleaf, ...
- springboot整合Thymeleaf模板引擎
引入依赖 需要引入Spring Boot的Thymeleaf启动器依赖. <dependency> <groupId>org.springframework.boot</ ...
- 解决SpringBoot页面跳转无法访问静态资源的问题
初学SpringBoot,写项目的时候遇到了问题,原本的页面是这样的 但启动项目后是这样的 这是因为thymeleaf中引入静态资源及模板需要使用到 th:xxx 属性,否则无法在动态资源中访问静态资 ...
- SpringBoot 结合 Thymeleaf 进行页面的跳转
1.引入thymeleaf依赖 <!--thymeleaf--> <dependency> <groupId>org.springframework.boot< ...
随机推荐
- URAL 1004 Sightseeing Trip(floyd求最小环+路径输出)
https://vjudge.net/problem/URAL-1004 题意:求路径最小的环(至少三个点),并且输出路径. 思路: 一开始INF开大了...无限wa,原来相加时会爆int... 路径 ...
- Python 全集变量
1.添加关键字: global 在要给变量从新赋值的时候添加. 全局变量都大写,局部变量都小写.
- R语言可视化学习笔记之添加p-value和显著性标记--转载
https://www.jianshu.com/p/b7274afff14f?from=timeline #先加载包 library(ggpubr) #加载数据集ToothGrowth data(&q ...
- hdu 6053 TrickGCD 筛法
TrickGCD Time Limit: 5000/2500 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Probl ...
- CentOS7 安装Perl
官网:http://www.cpan.org/src/ wget https:.tar.gz cd perl- ./Configure -des -Dprefix=$HOME/localperl ma ...
- Mybatis的SqlSession理解(一)
SqlSession是Mybatis最重要的构建之一,可以认为Mybatis一系列的配置目的是生成类似JDBC生成的Connection对象的statement对象,这样才能与数据库开启“沟通”,通过 ...
- Jtest的简单使用
Jtest主要用于快速测试自己的代码是否正确 条件,导入相应的Jtest包 @Test public void test() { System.out.println(" ...
- C++.运行时类型判断_测试代码
ZC:C++ 编程思想——运行时类型识别 - 浅墨浓香 - 博客园.html(https://www.cnblogs.com/5iedu/articles/5585895.html) -------- ...
- TRMM数据在arcgis打开
基本思路:地图配准 1将投影设置为plate carree(world) ,是在投影坐标系统下的世界中选择,当然为了输入坐标方便,设置属性genral中单位为度,显示为度分秒. 2 首先,要知道打开后 ...
- Lambda语法篇
函数式接口 函数式接口(functional interface 也叫功能性接口,其实是同一个东西).简单来说,函数式接口是只包含一个方法的接口. Lambda语法 包含三个部分 一个括号内用逗号分隔 ...