2020-10-12 08:32

好的,谢谢

2020-10-10 17:29

@JFinal 对于发送简单的邮件是成功的,只是“发送模板类邮件”这个api报错,麻烦大佬了

2020-10-10 17:22

@JFinal 我去除最后一句的renderText("Hello JFinal World.")后,依然报了相同的错误

2020-10-10 17:16

@JFinal 我这个地方就不懂了,从下面这两个方法来看,
HttpServletResponse response = (HttpServletResponse) Proxy.newProxyInstance(
getClass().getClassLoader(), new Class[]{HttpServletResponse.class}, new MockHttpServletResponse());
HttpServletRequest request = (HttpServletRequest) Proxy.newProxyInstance(
getClass().getClassLoader(), new Class[]{HttpServletRequest.class}, new MockHttpServletRequest());
request的response值与我的传参都没有关系,是我那个地方理解有误吗?
对于我的工程,其实就是在“非 maven 方式开发”这个demo的基础上添加了jfinal-mail-plugin插件而已

2020-10-10 16:57

@JFinal 应该没有吧,我debug了一下;request和response 是从 MailPro.java中获取的:
public void send(String to, List cc, String subject, String viewPath, Map dataMap, List attachments) {
HttpServletResponse response = (HttpServletResponse) Proxy.newProxyInstance(
getClass().getClassLoader(), new Class[]{HttpServletResponse.class}, new MockHttpServletResponse());
HttpServletRequest request = (HttpServletRequest) Proxy.newProxyInstance(
getClass().getClassLoader(), new Class[]{HttpServletRequest.class}, new MockHttpServletRequest());
for (Map.Entry entry : dataMap.entrySet()) {
request.setAttribute(entry.getKey(), entry.getValue());
}
RenderManager.me().getRenderFactory().getRender(viewPath).setContext(request, response).render();
String text;
try {
text = response.getWriter().toString();
send(to, cc, subject, text, attachments);
} catch (IOException e) {
throw new MailSendException("邮件发送失败!",e);
}
}

而在这时,request和response的取值就已经是null了,responseweinull导致最终的报错