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

}
相關文章
相關標籤/搜索