笔者在开发Java发送邮件中遇到一个非常奇怪的事情,在采用了Thymeleaf作为邮件模板时,报错如下:
Error resolving template [cert/sendThymeleafMailApi], template might not exist or might not be accessible by any of the configured Template Resolvers
在经历了一番搜索发现,原来是这里缺少了注解@ResponseBody,代码如下:
@GetMapping("/sendThymeleafMailApi") @ResponseBody @ApiOperation(value = "App - 发送App信息") private void sendThymeleafMailApi(@RequestParam(value = "id") Integer id) throws MessagingException { APPIDINFO appidinfo = certService.appIDInfoById(id); sendThymeleafMail(appidinfo); }
注意@Controller
@Controller@RequestMapping("cert") @Api
如果是@RestController,则就不需要前面说的注解@ResponseBody了。
学习更多相关知识,来这里吧。