Spring Boot 静态页面

博客介绍在Java项目里,于resources目录下创建static文件夹及/1/index.html文件,之后可通过http://localhost/1/index.html访问该HTML页面,还给出了转载来源。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

spring boot项目只有src目录,没有webapp目录,会将静态访问(html/图片等)映射到其自动配置的静态目录,如下

/static

/public

/resources

/META-INF/resources

首先,在resources目录下先建立static文件夹,在建立/1/index.html文件

http://localhost/1/index.html 和 http://localhost/1/index.html都可以访问index.html页面

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

/**
 * @Date 2018/8/29 0029
 */
@Controller
public class HtmlController {

    @RequestMapping("/1/index")
    public String text() {
        return "/1/index.html";
    }

}

 

转载于:https://www.cnblogs.com/tinya/p/9554290.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值