我在本地主机上的邮件中添加内联图像:
inline 'footerImage', 'image/jpg', new File('./web-app/images/mailAssets/suchebottomre.gif').readBytes()
哪个工作正常。当我部署到我的测试环境时,我收到此错误:
Class
java.io.FileNotFoundException
Message
cannot use ./web-app/images/mailAssets/alert_header_pre.png as an attachment as it does not exist
使用此日志:
Line | Method
->> 331 | inline in grails.plugin.mail.MailMessageBuilder
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 20 | doCall in de.docinsider.web.NotifierService$_contactUser_closure1
| 39 | sendMail . in grails.plugin.mail.MailService
| 13 | contactUser in de.docinsider.web.NotifierService
| 7 | doCall . . in de.docinsider.web.SendController$_closure1
| 195 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter . in grails.plugin.cache.web.filter.AbstractFilter
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run in java.lang.Thread
如何避免这种情况?
我还想通过以下方式实现资源加载器:
import org.springframework.context.ResourceLoaderAware
import org.springframework.core.io.ResourceLoader
class SendController implements ResourceLoaderAware {
@Autowired
ResourceLoader resourceLoader
def notifierService
def index() { }
def welcome = {
notifierService.contactUser(params.username, params.email, params.message)
render view:"/send/feedback", model:[name:params.username, message:params.message]
}
void setResourceLoader(ResourceLoader resourceLoader) {
resourceLoader = resourceLoader
}
}
这也行不通。
和:
inline 'headerImage', 'image/jpg', resourceLoader.getResource('/images/mailAssets/header_top.png')
inline 'footerImage', 'image/jpg', resourceLoader.getResource('/images/mailAssets/footer_bottom.gif')
在服务中。