spring-boot - 如何在spring boot中访问外部项目资源
问题描述
我正在用 SpringBoot 建立一个网站。目前使用百里香。
我目前正在运行 3 个项目,每个项目名为 ko, en, payment。
我目前的情况是通过单击 en 项目内 purchase.html 中的按钮来发送邮件。
发送邮件负责支付项目。
原因是在 en 项目中单击 purchase.html 中的按钮时要实现相同的功能。
在任何情况下,在发送电子邮件时,都会使用单独的 html 作为内容来撰写电子邮件内容。
ApplicationContext context = new AnnotationConfigApplicationContext(ThymeleafViewResolverConfig.class);
Context ctx = new Context(Locale.KOREA);
ctx.setVariable("name", purchaseModel.getReceiverManagerName() + "님");
TemplateEngine templateEngine = context.getBean(TemplateEngine.class);
final String htmlContent = templateEngine.process("orderMailTemplate_ko", ctx);
textBodyPart.setContent(htmlContent, "text/html; charset=UTF-8");
当调用外部 html 时,它是使用模板引擎导入的,如下面的代码。
所以我尝试的是:
<img th:src="@{/img/test.jpg}"
`<img th:src="@{img/test.jpg}"
仍然存在尝试加载失败的情况。
于是我搜索了如何加载外部项目资源,但找不到合适的解决方案。
请给我一个提示。
解决方案
推荐阅读
- python - 对于字符串中的某些字符,在紧接之前插入重复
- git - 每个 PR 都会有一个 git commit。如何清理 git 提交历史?
- ios - 如何以编程方式访问 iOS 13 中的应用程序语言?
- google-apps-script - Google Apps 脚本 -- 隐藏“运行脚本”通知
- mysql - SQL 语句运行缓慢
- c# - 从 POST 请求中使用嵌套的 JSON,无法将嵌套的 JSON 分配给我的班级
- keycloak - CAS 6.1 - Pac4J 的状态参数为空
- c - 用另一个指针强制转换的结构指针
- java - 如何在使用并行方法时使 forEach 循环线程中的单个任务安全?
- spring - 尝试在 Spring Boot 2.1 中下载没有扩展名的文件时出现 404