template might not exist or might not be accessible by any of the configured Template Resolvers

使用的SpringBoot版本是2.0.3.RELEASE
1.src/main/resources文件下模板文件夹名称是templates有s
2.pom文件中加入以下依赖



    org.springframework.boot
    spring-boot-starter-thymeleaf



    net.sourceforge.nekohtml
    nekohtml

3.application.yml文件中

spring:
  thymeleaf:
    mode: HTML
    encoding: utf-8
    cache: false

4.加不加斜杠都不会解析出错(本地),但是有网友说在本地部署没有问题,打jar部署到正式环境加斜杠会出错。

@RequestMapping(value = "/index")
    public String index(Model model, HttpServletRequest request) {
        HttpSession session = request.getSession();
        UserDTO UserDTO = userService.selectByUserName(session.getAttribute(
                "username").toString());
        List> menus = menuService.listMenuTree(UserDTO
                .getUserId());
        model.addAttribute("menus", menus);
        model.addAttribute("name", UserDTO.getName());
        model.addAttribute("username", UserDTO.getUsername());
        return "/view/main";
}

你可能感兴趣的:(SpringBoot)