mail.jsp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <%@page contentType="text/html;charset=UTF-8"%>
  2. <%@page import="org.springframework.context.ApplicationContext"%>
  3. <%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
  4. <%@page import="com.mossle.core.mail.MailFacade"%>
  5. <%@page import="com.mossle.core.mail.MailHelper"%>
  6. <%
  7. String action = request.getParameter("action");
  8. ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(application);
  9. MailFacade mailFacade = (MailFacade) ctx.getBean("mailFacade");
  10. MailHelper mailHelper = (MailHelper) ctx.getBean("mailHelper");
  11. if ("update".equals(action)) {
  12. String mode = request.getParameter("mode");
  13. String testMail = request.getParameter("testMail");
  14. mailHelper.getDefaultMailServerInfo().setMode(mode);
  15. mailHelper.getDefaultMailServerInfo().setTestMail(testMail);
  16. response.sendRedirect("mail.jsp");
  17. } else if("send".equals(action)) {
  18. mailFacade.sendMail("lingo.mossle@gmail.com", "test", "test");
  19. response.sendRedirect("mail.jsp");
  20. }
  21. pageContext.setAttribute("mailFacade", mailFacade);
  22. pageContext.setAttribute("mailHelper", mailHelper);
  23. %>
  24. <html>
  25. <head>
  26. <meta charset="utf-8">
  27. <title>mail</title>
  28. <style>
  29. tbody tr:nth-child(odd) td,
  30. tbody tr:nth-child(odd) th {
  31. background-color: #f9f9f9;
  32. }
  33. </style>
  34. </head>
  35. <body>
  36. <form method="post" action="mail.jsp?action=update">
  37. <table border="1">
  38. <tbody>
  39. <tr>
  40. <td>是否测试模式</td>
  41. <td><input type="checkbox" name="mode" value="TEST" ${mailHelper.defaultMailServerInfo.mode ? 'TEST' : 'checked'}></td>
  42. </tr>
  43. <tr>
  44. <td>测试邮箱</td>
  45. <td><input type="text" name="testMail" value="${mailHelper.defaultMailServerInfo.testMail}"></td>
  46. </tr>
  47. <tr>
  48. <td colspan="2">
  49. <button>修改</button>
  50. &nbsp;
  51. <button type="button" onclick="location.href='mail.jsp?action=send'">发送邮件</button>
  52. </td>
  53. </tr>
  54. </tbody>
  55. </table>
  56. </form>
  57. </body>
  58. </html>