private void configJavaMailSender() {
   Boolean changed =
       (Boolean) PropertiesUtil.getObject(SysParameterEnum.MAIL_PROPERTIES_CHANGED, Boolean.class);
   if ((changed == null) || (changed.booleanValue())) {
     this.javaMailSender.setDefaultEncoding("UTF-8");
     this.javaMailSender.setHost(
         (String) PropertiesUtil.getObject(SysParameterEnum.MAIL_HOST, String.class));
     this.javaMailSender.setPort(
         ((Integer) PropertiesUtil.getObject(SysParameterEnum.MAIL_PORT, Integer.class))
             .intValue());
     String mailname = (String) PropertiesUtil.getObject(SysParameterEnum.MAIL_NAME, String.class);
     this.javaMailSender.setUsername(mailname.substring(0, mailname.indexOf("@")));
     this.javaMailSender.setPassword(
         (String) PropertiesUtil.getObject(SysParameterEnum.MAIL_PASSWORD, String.class));
     Properties properties = new Properties();
     properties.setProperty(
         "mail.smtp.auth",
         ((Boolean) PropertiesUtil.getObject(SysParameterEnum.MAIL_STMP_AUTH, Boolean.class))
             .toString());
     properties.setProperty(
         "mail.smtp.timeout",
         (String) PropertiesUtil.getObject(SysParameterEnum.MAIL_STMP_TIMEOUT, String.class));
     this.javaMailSender.setJavaMailProperties(properties);
     this.log.info(
         "Configuration Mail Sender successful Host: {}, Username {}, mail.smtp.auth: {}",
         new Object[] {
           this.javaMailSender.getHost(),
           this.javaMailSender.getUsername(),
           this.javaMailSender.getJavaMailProperties().get("mail.smtp.auth")
         });
     PropertiesUtil.setObject(SysParameterEnum.MAIL_PROPERTIES_CHANGED, Boolean.FALSE);
   }
 }
 private void sendHTMLMail(String to, String subject, String text) throws MessagingException {
   configJavaMailSender();
   MimeMessage message = this.javaMailSender.createMimeMessage();
   MimeMessageHelper helper = new MimeMessageHelper(message, true, "UTF-8");
   helper.setFrom((String) PropertiesUtil.getObject(SysParameterEnum.MAIL_NAME, String.class));
   helper.setTo(to);
   helper.setSubject(subject);
   helper.setText(text, true);
   this.javaMailSender.send(message);
 }
Beispiel #3
0
public class PhotoTag extends LegendShopTag {
  private String item;
  private String prefix = PropertiesUtil.getPhotoPathPrefix();

  public void doTag() throws IOException {
    String str = request().getContextPath() + this.prefix + this.item;
    write(str);
  }

  public void setItem(String item) {
    this.item = item;
  }
}
 public void parseExportPageSize() {
   if (!FoundationUtil.isDataForExport(this, ThreadLocalContext.getRequest())) { // 非导出情况
     this.setPageSize(PropertiesUtil.getObject(SysParameterEnum.PAGE_SIZE, Integer.class));
   }
 }