錯誤: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了;

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