Spring Boot 静态页面

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

/static

/public

/resources

/META-INF/resources

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

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

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";
    }

}
相关文章
相关标签/搜索