qq_24534807
qq_24534807
采纳率34.5%
2017-05-25 06:33 阅读 4.3k

Springboot ModelAndView???

直接上代码~

 @Configuration
public class ExportAlarmController {

    @Bean(name = "csvView")
    public CSVView cSVView() {
        return new CSVView();
    }

    @Autowired
    ExportAlarmService exportAlarmService;

    @SuppressWarnings({ "unchecked", "rawtypes" })
    @RequestMapping(value = "/exportAlarm", method = RequestMethod.POST)
    public ModelAndView exportAlarm(HttpServletRequest request, HttpServletResponse response) throws Exception {

        System.out.println("-----------------exportAlarm------------------");

        Map requestValue = request.getParameterMap();

        List list = exportAlarmService.exportAlarm(requestValue);

        Map result = new HashMap();

        result.put("list", list);
        result.put("name", "Alarm");

        return new ModelAndView("csvView", result);
    }

}


执行上面的代码后出现错误~

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

请问这个要怎么解决呢?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • sun1021873926 夕阳雨晴 2017-05-25 10:46

    new ModelAndView("csvView", result) 这个所指向的页面似乎不存在……

    点赞 评论 复制链接分享
  • lihongbiao0610 lihongbiao0610 2017-05-25 11:26

    先检查配置:

    THYMELEAF (ThymeleafAutoConfiguration)

    #spring.thymeleaf.check-template-location=true
    #spring.thymeleaf.prefix=classpath:/templates/
    #spring.thymeleaf.excluded-view-names= # comma-separated list of view names that should be excluded from resolution
    #spring.thymeleaf.view-names= # comma-separated list of view names that can be resolved
    #spring.thymeleaf.suffix=.html
    #spring.thymeleaf.mode=HTML5
    #spring.thymeleaf.encoding=UTF-8
    #spring.thymeleaf.content-type=text/html # ;charset= is added
    #spring.thymeleaf.cache=true # set to false for hot refresh
    然后看spring.thymeleaf.prefix配置对应的路径下是否有csvView.html文件

    点赞 评论 复制链接分享

相关推荐