Springboot 整合 html

Springboot 整合 html,有些小伙伴们参与的项目不是前后端分离的,或者需要一些中转页去做,jsp的方式之前分享过了,现在分享一下html标签的方式。

项目下载地址:https://download.csdn.net/download/qq_27535933/11435600
博客地址:https://blog.csdn.net/qq_27535933/article/details/97397582

创建项目的步骤就省略的。。。。。。

Springboot 整合 html应用工具:Springboot  gradle-4.6 java-8

首先我们引包

plugins {
    id 'org.springframework.boot' version '2.1.6.RELEASE'
    id 'java'
}

apply plugin: 'io.spring.dependency-management'

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

新增配置:

#端口号
server.port=8080
# 配置
spring.thymeleaf.prefix=classpath:/templates/

在templates下创建创建一个html标签

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8"/>
    <title>Hello World!</title>
</head>
<body>
    Hello World!
</body>
</html>

写一个测试类

package com.example.rest;

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

/**
 * @author YanChengLong
 * @date 2019/7/25
 * @desc 测试
 */
@Controller
public class Test {

    @RequestMapping("/test")
    public String test(){
        return "/index";
    }

}

项目的目录结构:

小伙伴们有哪些问题或者意见,请私信或者与我联系,感谢

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值