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< ...
随机推荐
- 【Luogu P2764】最小路径覆盖问题
网络流 \(24\) 题之一. Problem Description 给出一个 \(n\) 个点 \(m\) 条边的 \(DAG\) ,求最小路径点覆盖,并输出路径选择方案. Input Forma ...
- Java中的异常 Exceptions
1. 概念 exception是“exceptional event”的缩写,是指执行程序中发生的事件,破坏了程序的正常执行流程.Java 异常处理机制使程序更加健壮易于调试,它可以告诉程序员三个问题 ...
- CentOS6.5下安装、配置SSH
1.登录CentOS 6.5系统,使用root用户登录,如果为非root用户则执行 su 或 su - 或 su root 或 su - root 输入root密码切换为root用户. 2.查看SSH ...
- 学习笔记16—Matlab 基础集
1.常用相关 [r, p] = corr(X,Y), [r, p] = partialcorr(X,Y, Z) , 其中Z是协变量. 2.TD_age = importdata('F:\BrainAg ...
- python中函数与函数式编程(一)
在学习之前,我们先去区分面对对象.面对过程.函数式编程他们之间的区别,从改图可以看出,他们之间不是完全相同的,也不是没有任何相同点的 1.函数和过程的基本认识 def func1(): "& ...
- js获取url传递得参数
方法一:正则法 function getQueryString(name) { var reg = new RegExp('(^|&)' + name + '=([^&]*)(& ...
- 用 EasyUEFI 在 Win8/10 中硬盘安装 Ubuntu16.04图文教程
用 EasyUEFI 在 Win8/10 中硬盘安装 Ubuntu 作者:TeliuTe 来源:基础教程网 1.准备Ubuntu安装文件 1)下载带amd的64位 Ubuntu 桌面版光盘镜像文件,如 ...
- ubuntu 16.04 下安装smplayer视频播放器
安装平台:ubuntu 16.04 1.sudo apt-add-repository ppa:rvm/smplayer 2.sudo apt-get update 3.sudo apt-get in ...
- GROUP by 方法 C#
1.用两层循环计算,前提条件是数据已经按分组的列排好序的. DataTable dt = new DataTable(); dt.Columns.AddRange(new DataColumn[] { ...
- 远程服务器返回了意外相应:(413) Request Entity Too Large。
在从客户端向WCF服务端传送较大数据(>65535B)的时候,发现程序直接从Reference的BeginInvoke跳到EndInvoke,没有进入服务端的Service实际逻辑中,怀疑是由于 ...