1、Controller控制层
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import com.search.yaco.service.IEmpService;
/**
* test控制
* @author: yaco
* @date 2018年12月10日上午9:42:33
*/
@RestController
@RequestMapping("/")
public class TestController {
@Autowired
private IEmpService empService;
@RequestMapping("/")
public ModelAndView index() {
ModelAndView mv = new ModelAndView();
mv.setViewName("homepage");
return mv;
}
}
2、application.properties配置文件
#thymeleaf模板配置
spring.thymeleaf.cache=false
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.encoding=UTF-8
#静态资源访问路径
spring.mvc.static-path-pattern=/static/**
#静态资源路径配置
spring.resources.static-locations=classpath:/static
3、创建自己的主页---homepage.html 注意路径:创建在resoutces/templates 下面
4、直接运行,访问localhost:8080