首页 > 其他分享 >230123_50_SpringBoot入门

230123_50_SpringBoot入门

时间:2023-01-23 23:33:33浏览次数:39  
标签:index SpringBoot controller 50 thymeleaf 首页 230123 org 图标

  • 首页和图标定制
  • 首页:新建index文件,放到静态资源加载目录
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>首页-测试</title>
</head>
<body>
<h1>首页</h1>

</body>
</html>

测试结果:

  • 通过controller去跳到首页,而不是通过加载静态资源的方式加载首页

  • controller访问index

package com.bill.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @Auther: wangchunwen
 * @Date: 2023/1/23 - 01 - 23 - 22:36
 * @Description: com.bill.controller
 * @version: 1.0
 */
@Controller
public class IndexController {
    @RequestMapping("/index")
    public String index(){
        return "index";
    }
}
  • 导入thymeleaf依赖
<dependency>
   <groupId>org.thymeleaf</groupId>
   <artifactId>thymeleaf-spring5</artifactId>
</dependency>
<dependency>
   <groupId>org.thymeleaf.extras</groupId>
   <artifactId>thymeleaf-extras-java8time</artifactId>
</dependency>
  • 测试结果:

  • 图标定制:默认每个网页图标是空的,例如下面的第一个图片,B站和微博都是有图标。

  • 在public目录下准备一个图标

  • 关闭默认图标
spring.mvc.favicon.enabled = false

测试结果:

标签:index,SpringBoot,controller,50,thymeleaf,首页,230123,org,图标
From: https://www.cnblogs.com/wcwblog/p/17065690.html

相关文章

  • SpringBoot-JDBC
    1.引入JDBC依赖<!--JDBC--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-jdbc</art......
  • 20230123
    新年快乐!复习位运算bit有两个状态,分别是0和1。0xFF=-1。0x7F=127。m位的二进制数中,最低位为第\(0\)位从右到左以此类推,最高位位\(m-1\)位。以最高......
  • springboot文件操作之更新头像
    就是在个人中心中,点击更改个人头像,上面立马更新的那种:利用了springboot的文件上传的技术,不知道的可以看看这个博客  由于这个侧边栏,上面栏,主屏幕属于三个部分,所以可......
  • springboot+vue整合文件,照片上传
    1.建立一个File的数据库CREATETABLE`sys_file`(`id`int(11)NOTNULLAUTO_INCREMENTCOMMENT'id',`name`varchar(255)COLLATEutf8mb4_unicode_ciDEFAUL......
  • SpringBoot单元测试
    接上一篇:https://www.cnblogs.com/uncleyong/p/17065293.html添加依赖<dependency><groupId>org.springframework.boot</groupId><a......
  • SpringBoot整合MyBatis
     添加pom依赖<dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.16.18<......
  • SpringBoot集成JWT实现token验证
    一、简介Jwt全称是:jsonwebtoken。它将用户信息加密到token里,服务器不保存任何用户信息。服务器通过使用保存的密钥验证token的正确性,只要正确即通过验证。优点简洁......
  • 【SpringBoot】源码之 Java16新特性:【instanceOf】
    在java16之前,我们要进行instanceOf判断一般会伴随着强转操作,就像这样:if(objinstanceofString){Strings=(String)obj;...}这样的书写方式看起来比......
  • X264在龙芯3A5000的编译
    X264在龙芯3A5000的编译 修改方法1)./configure执行配置脚本,若出现“configure:error:cannotguessbuildtype;youmustspecifyone”执行2)步骤,如果未出现报错......
  • 【230123-1】已知:m-n=23,根号m+根号n=23 求:m,n (据传为77年高考题)
    换元法解方程......