本篇博客仅为自己提个醒:如何跳转页面而不麻烦控制器。

当我们创建 Spring Boot 项目时(勾选了 Thymeleaf 和 Web),目录结构会是如下:

      

其中图二是我创建了一个 html 文件夹以及一个 index.html 页面。

如果要实现静态页面的跳转(不经过控制器),静态文件必须放在 static 目录下。

因为访问 templates 目录下的文件都需要经过控制器。

index.html

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<a href="/html/login.html">登录</a>
</body>
</html>

login.html

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="#">
<input type="text" name="username" placeholder="Username">
<input type="password" name="password" placeholder="Password">
<input type="submit" value="Login">
</form>
</body>
</html>

好啦,可以在浏览器输入 http://localhost:8080/ 试下了。

Spring Boot 静态页面跳转的更多相关文章

  1. Spring Boot 静态页面

    spring boot项目只有src目录,没有webapp目录,会将静态访问(html/图片等)映射到其自动配置的静态目录,如下 /static /public /resources /META-IN ...

  2. Spring Boot—05页面跳转

    package com.smartmap.sample.ch1.controller.view; import org.springframework.stereotype.Controller; i ...

  3. Spring Boot 静态资源处理

    spring Boot 默认的处理方式就已经足够了,默认情况下Spring Boot 使用WebMvcAutoConfiguration中配置的各种属性. 建议使用Spring Boot 默认处理方式 ...

  4. Spring Boot静态资源处理

    Spring Boot静态资源处理 8.8 Spring Boot静态资源处理 当使用Spring Boot来开发一个完整的系统时,我们往往需要用到前端页面,这就不可或缺地需要访问到静态资源,比如图片 ...

  5. Spring Boot 静态资源处理(转)

    Spring Boot 静态资源处理 Spring Boot 系列 Spring Boot 入门 Spring Boot 属性配置和使用 Spring Boot 集成MyBatis Spring Bo ...

  6. 从零开始的Spring Boot(3、Spring Boot静态资源和文件上传)

    Spring Boot静态资源和文件上传 写在前面 从零开始的Spring Boot(2.在Spring Boot中整合Servlet.Filter.Listener的方式) https://www. ...

  7. 十二、 Spring Boot 静态资源处理

    spring Boot 默认为我们提供了静态资源处理,使用 WebMvcAutoConfiguration 中的配置各种属性. 建议大家使用Spring Boot的默认配置方式,如果需要特殊处理的再通 ...

  8. 16. Spring boot 错误页面

      默认效果:1).浏览器,返回一个默认的错误页面 1.1 请求头 1.2返回结果 2).如果是其他客户端,默认响应一个json数据 2.1请求头 2.2返回结果 { "timestamp& ...

  9. Spring MVC - 静态页面

    环境搭建 以下示例显示如何使用Spring MVC Framework编写一个简单的基于Web的应用程序,它可以使用<mvc:resources>标记访问静态页面和动态页面.首先使用Int ...

随机推荐

  1. 苹果审核之遇到IPV6问题被拒的解决方法

    情景: 等待苹果审核上线时,发现因为IPV6被拒了.这是悲剧,以下是苹果审核给我的理由: We discovered one or more bugs on Wi-Fi connected to an ...

  2. centos7.2下安装mysql5.7数据库

    服务器上的mysql安装了一个8.0.12版本的,本地的是一个5.7版本的,今天删除了重新安装的5.7版本的,下面是所有的名命令 跟着走就会安装上了.   配置源 wget http://dev.my ...

  3. java8新特性—四大内置核心接口

    java8新特性-四大内置核心接口 四大内置核心接口 //消费型接口 Consumer<T>:: vode accept(T t); //供给型接口 Supplier<T>:: ...

  4. The listener supports no services oracle注册监听

    问题登场: [oracle@my-e450 ~]$ lsnrctl status …… The listener supports no servicesThe command completed s ...

  5. Centos7 安装使用virtualenvwrapper

    退出所有的虚拟环境,在物理环境下安装 1.下载安装virtualenvwrapper pip3 install virtualenvwrapper 2.查看python3的文件和virtualenvw ...

  6. SQL之单表与多表查询

    DML语句使用 source  路径  :把SQL脚本导入到数据库中 查询语句类型:[简单查询|多表查询|子查询] 投影:select    字段名,字段名   from   表名   where   ...

  7. 【Linux】-- 认识bash shell

    一.前言 我们知道管理整个计算机硬件的其实是系统的内核,这个内核是需要被保护的,所以我们一般用户就只能通过shell来跟内核通信,以让内核达到我们所想要达到的工作.那么Linux系统有多少shell可 ...

  8. 关于微信小程序开发环境苹果IOS真机预览报SSL协议错误问题解决方案

                              微信小程序开发环境苹果IOS真机预览报SSL协议错误问题 原文来自:https://blog.csdn.net/qq_27626333/articl ...

  9. windows API下的模板缓冲(stencil buffer)

    在windows API搭建的OpenGL窗口中使用模板缓冲,需要在像素格式描述表中设置stencil buffer位宽为8,这样窗口会自动生成stencil buffer,然后可以在opengl环境 ...

  10. day15_7.17正则表达式与re模块

    一.正则表达式 在用户登录注册,以及身份验证时,会发现,如果在手机号的窗口输入字母等不是手机号的格式的字符串时,会报错,这种筛选字符串的功能就是由正则表达式提供. 正则表达式是几乎所有编程语言都会设计 ...