springboot2.1.0+thymeleaf 整合 问题如下:死活进不去,大哥们求助,我 QQ571726193,或者留言,提前谢过 - V2EX
571726193
V2EX    Java

springboot2.1.0+thymeleaf 整合 问题如下:死活进不去,大哥们求助,我 QQ571726193,或者留言,提前谢过

  •  
  •   571726193 Mar 19, 2019 9838 views
    This topic created in 2615 days ago, the information mentioned may be changed or developed.

    ##Springboot+thymeleaf 整合问题 ##接口

    @Controller public class HelloController { @Autowired private ApiLogService apiLogService; @RequestMapping("/getLog") public String getLog(Model model) { model.addAttribute("apiLogList",apiLogService.getList()); return "list"; } } 

    ##页面错误信息

    This application has no explicit mapping for /error, so you are seeing this as a fallback. Tue Mar 19 17:31:23 CST 2019 There was an unexpected error (type=Internal Server Error, status=500). Error resolving template [getLog], template might not exist or might not be accessible by any of the configured Template Resolvers org.thymeleaf.exceptions.TemplateInputException: Error resolving template [getLog], template might not exist or might not be accessible by any of the configured Template Resolvers at。。。 

    ##后台错误信息

    org.thymeleaf.exceptions.TemplateInputException: Error resolving template [getLog], template might not exist or might not be accessible by any of the configured Template Resolvers 

    ##页面目录

    templates/list.html 

    ##配置信息(仅此一个关于 thymeleaf 的配置)

    spring.thymeleaf.cache=false 
    9 replies    2019-03-20 11:12:08 +08:00
    wineast
        1
    wineast  
       Mar 19, 2019
    看日志是 resover 的配置问题,controller 返回的“ list ”字符串,无法定位到“ template/list.html
    MrAQL
        2
    MrAQL  
       Mar 19, 2019
    spring:
    thymeleaf:
    cache: false
    model: HTML5
    prefix: classpath:/templates/
    suffix: .html
    你可以指定下模板路径看看可不可以
    yiyi11
        3
    yiyi11  
       Mar 19, 2019 via Android
    不知道为啥,看到留 qq 就觉得很 low。
    huruwo
        4
    huruwo  
       Mar 19, 2019
    @yiyi11 这是病
    Betsy
        5
    Betsy  
       Mar 19, 2019 via iPhone
    楼主如果使用的是 maven 管理的话,大概率在 pom.xml 中少写了一条与 thymeleaf 相关的依赖,名字应该为 spring-boot-starter-thymeleaf
    tt0411
        6
    tt0411  
       Mar 19, 2019
    public String getLog(Model model) 方法前加个注解 @ResponseBody
    nita22
        7
    nita22  
       Mar 20, 2019
    跟 5 楼说的一样,先看看依赖有没有引错。另外,规范一点的话,@RequestMapping 里面还是把对应的方法给填上吧
    Junwwwww
        8
    Junwwwww  
       Mar 20, 2019
    templates 在 resources 目录下吗?
    notreami
        9
    notreami  
       Mar 20, 2019
    @RequestMapping("/getLog")
    public ModelAndView getLog(ModelAndView mv) {
    mv.setViewName("/list");
    mv.addObject("apiLogList",apiLogService.getList());
    return mv;
    }
    }
    About     Help     Advertise     Blog     API     FAQ     Solana     2976 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 50ms UTC 14:51 PVG 22:51 LAX 07:51 JFK 10:51
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86