Spring Boot 静态页面

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