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

当我们创建 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. 【IPHONE开发-OBJECTC入门学习】复制对象,深浅复制

    转自:http://blog.csdn.net/java886o/article/details/9046273 #import <Foundation/Foundation.h> int ...

  2. 设计模式:单例模式(singleton)

    singleton模式属于创建型设计模式.其作用是在程序设计中,对于某一个类而言,全局只能存在一个实例对象. 下面以C++为例,对单例模式进行说明: 1. 最基本单例模式(单线程) class Sin ...

  3. 史上最全的Spring Boot Cache使用与整合

    一:Spring缓存抽象# Spring从3.1开始定义了org.springframework.cache.Cache和org.springframework.cache.CacheManager接 ...

  4. DjangoForm 提交验证

    用户提交数据的验证 1.创建模版 -- class LoginForm(forms.Form):.... 2.将请求交给模版,创建一个对象 -- obj = LoginForm(request.POS ...

  5. LINUX内核CPU负载均衡机制【转】

    转自:http://oenhan.com/cpu-load-balance 还是神奇的进程调度问题引发的,参看Linux进程组调度机制分析,组调度机制是看清楚了,发现在重启过程中,很多内核调用栈阻塞在 ...

  6. Rust中的Vector类型

    常用类型操作, 如python中的list,turple,dictory等, 更方常编程常用数据的处理. fn main() { let v = vec![, , , , ]; let third: ...

  7. linux 环境下 apache tomcat 安装jenkins

    参考文档: https://blog.51cto.com/12629984/1980034 https://www.cnblogs.com/lxs1314/p/8567652.html https:/ ...

  8. 接口八问 & 接口测试质量评估标准

    接口八问 关于接口的具体信息,可以通过以下八个问题进行了解: 接口的请求地址? 接口的作用? 接口的请求方式? 接口是否是用户相关? 接口是否存在上送数据,上送数据是什么? 接口返回的报文头和编码? ...

  9. webpy安装

    C:\Users\ceshi>python -m pip install web.pyCollecting web.py Downloading web.py-0.38.tar.gz (91kB ...

  10. leetcode203. 移除链表元素

    方法一(删除头结点时另做考虑) class Solution { public: ListNode* removeElements(ListNode* head, int val) { if(head ...