小编meg*_*och的帖子

Spring启动映射静态html

我想创建spring boot web应用程序.

我有两个静态html文件:one.html,two.html.

我想将它们映射如下

localhost:8080/one
localhost:8080/two
Run Code Online (Sandbox Code Playgroud)

不使用模板引擎(Thymeleaf).

怎么做?我已经尝试了很多方法来做到这一点,但我有404错误或500错误(圆形视图路径[one.html]:将调度回当前处理程序URL).

OneController.java是:

@Controller
public class OneController {
    @RequestMapping("/one")
    public String one() {
        return "static/one.html";
    }
}
Run Code Online (Sandbox Code Playgroud)

项目结构是

在此输入图像描述

spring-mvc static-html spring-boot

2
推荐指数
1
解决办法
7743
查看次数

标签 统计

spring-boot ×1

spring-mvc ×1

static-html ×1