Thymeleaf默认界面为index.html
如果在templates中存在index.html,输入地址http://localhost:8080/会跳转到index.html
如果没有就报错404
如果想自己设置默认界面
网上查不到像web.xml里那样设置< welcome-file-list>那么简单的
只找到页面跳转的憨批方法。。。
package com.test.springboottest.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class FirstHtmlController {
@RequestMapping("/")
public String toFirstHtml(){
return "getUser";
}
}
application.yml里加上这个前缀后缀属性
thymeleaf:
prefix: classpath:/templates/
suffix: .html
设置一个控制器@RequestMapping("/"),return想要的界面
输入地址http://localhost:8080/就跳到了我想要的界面getUser.html