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

当我们创建 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. python从入门到放弃之守护进程

    # ### 守护进程 默认情况下,主进程要等待所有子进程执行完毕之后,才会关闭程序,释放资源守护进程进行在主进程代码执行结束之后,就直接关闭;守护进程守护的是主进程 语法: 进程.daemon = T ...

  2. Django 中使用 js 操作 cookies

    session与cookie对比 Cookie: 保存在用户浏览器端的键值对 本地可以修改:如果有敏感信息,可以被看到 Session: 保存在服务器端的键值对 服务端:保存键值对{'随机字符串':{ ...

  3. loadrunner 添加检查点

    1.首先使用录制的方式,把论坛的代码编写完成后,要判断的执行前插入检查点,使用右键方式,弹出的下拉的菜单中进行选择“insert”的选项. 2.就在弹出下一级的菜单中,进行选中一个为“new step ...

  4. LeetCode3-Longest_Substring_Without_Repeating_Characters

    参考思路 https://github.com/azl397985856/leetcode/blob/master/problems/3.longestSubstringWithoutRepeatin ...

  5. LG3812 「模板」线性基 线性基

    问题描述 LG3812 题解 线性基是一类擅长解决异或问题的数据结构(也不算数据结构吧...就是一种玄学的东西) 对于数列 \(a\) ,它的线性基 \(d\) 为 出现 \(1\) 的最高位在第 \ ...

  6. python爬虫之获取页面script里面的内容

    这是网页上的script 我要获取的是00914这个数字  直接使用正则表达式即可 运行结果: 源码: import re from bs4 import BeautifulSoup from url ...

  7. 【oracle】ORA-12638 : 身份证明检索失败

    sqlnet.ora 1.删了 2.#注释了 背后缘由:待写

  8. The 13th Chinese Northeast Collegiate Programming Contest

    题解: solution Code: A. Apple Business #include<cstdio> #include<algorithm> #include<ve ...

  9. ESA2GJK1DH1K升级篇: 快速的移植升级程序到自己的项目(APP用户程序制作)

    前言 用户程序比较简单,但是起着至关重要的作用 用户程序是和BootLoader程序相互配合的 拷贝文件到自己的项目 APP用户程序的 stmflash.c stmflash.h 和 上一节的Boot ...

  10. Bootstrap-table实现动态合并相同行

    Bootstrap-table  表格合并相同名字的列 @编写function() /** * 合并行 * @param data 原始数据(在服务端完成排序) * @param fieldName ...