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

笔者在开发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了;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章