当前位置: 首页>>代码示例>>Java>>正文


Java VelocityEngineUtils.mergeTemplateIntoString方法代码示例

本文整理汇总了Java中org.springframework.ui.velocity.VelocityEngineUtils.mergeTemplateIntoString方法的典型用法代码示例。如果您正苦于以下问题:Java VelocityEngineUtils.mergeTemplateIntoString方法的具体用法?Java VelocityEngineUtils.mergeTemplateIntoString怎么用?Java VelocityEngineUtils.mergeTemplateIntoString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.ui.velocity.VelocityEngineUtils的用法示例。


在下文中一共展示了VelocityEngineUtils.mergeTemplateIntoString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendEmail

import org.springframework.ui.velocity.VelocityEngineUtils; //导入方法依赖的package包/类
@Override
public void sendEmail(final UserDTO user, String url) {
    MimeMessagePreparator preparator = new MimeMessagePreparator() {
        public void prepare(MimeMessage mimeMessage) throws Exception {
            MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
            message.setTo(user.getEmail());
            message.setSubject(SUBJECT);
            message.setFrom(EMAIL_FROM); // could be parameterized...
            Map model = new HashMap();
            model.put("user", user);
            model.put("url", url);
            String text = VelocityEngineUtils.mergeTemplateIntoString(
                    velocityEngine, "org/enricogiurin/sushibar/registration-confirmation.vm", model);
            message.setText(text, true);
        }
    };
    this.emailSender.send(preparator);
}
 
开发者ID:egch,项目名称:sushi-bar-BE,代码行数:19,代码来源:EmailSenderImpl.java

示例2: sendMailWithTemplate

import org.springframework.ui.velocity.VelocityEngineUtils; //导入方法依赖的package包/类
@Override
public void sendMailWithTemplate(final TemplateMailTO mailParameters) throws MailException {
    MimeMessagePreparator preparator = new MimeMessagePreparator() {
        @Override
        public void prepare(MimeMessage mimeMessage) throws Exception {
            MimeMessageHelper message = new MimeMessageHelper(mimeMessage);

            message.setTo(mailParameters.getToMailAddress());
            message.setFrom(mailParameters.getFromMailAddress());
            message.setSubject(mailParameters.getSubject());
            if (mailParameters.hasCcMailAddress()) {
                message.setCc(mailParameters.getCcMailAddress());
            }
            if (mailParameters.hasReplyTo()) {
                message.setReplyTo(mailParameters.getReplyTo());
            }
            String text = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, mailParameters.getTemplateLocation(), mailParameters.getTemplateProperties());
            log.debug("*** TEST text='" + text + "'");
            message.setText(text, true);
            message.setValidateAddresses(true);

        }
    };
    this.mailSender.send(preparator);
}
 
开发者ID:huihoo,项目名称:olat,代码行数:26,代码来源:MailServiceImpl.java

示例3: getOpenfireHttpAuthProperties

import org.springframework.ui.velocity.VelocityEngineUtils; //导入方法依赖的package包/类
/**
 * Render the http auth properties file to be used with openfire
 *
 * @param request
 *            the request to use
 * @return the rendered properties
 */
public static String getOpenfireHttpAuthProperties(HttpServletRequest request) {
    // TODO change JSPs to VM and parse the http_auth.properties template
    VelocityEngine engine = ServiceLocator.findService(VelocityEngine.class);
    Map<String, Object> context = new HashMap<String, Object>();
    context.put("defaultHost", ApplicationProperty.WEB_SERVER_HOST_NAME.getValue());
    context.put("defaultPort", ApplicationProperty.WEB_HTTP_PORT.getValue());
    context.put("internalHost", request.getServerName());
    context.put("internalPort", request.getServerPort());
    if (request.isSecure()) {
        context.put("internalProtocol", "https");
    } else {
        context.put("internalProtocol", "http");
    }
    context.put("defaultPortHttps", ApplicationProperty.WEB_HTTPS_PORT.getValue());
    context.put("context", request.getContextPath());
    String render = VelocityEngineUtils.mergeTemplateIntoString(engine,
            VELOCITY_TEMPLATE_HTTP_AUTH_PROPERTIES, context);
    return render;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:27,代码来源:XmppController.java

示例4: buildMessageBody

import org.springframework.ui.velocity.VelocityEngineUtils; //导入方法依赖的package包/类
@Override
public String buildMessageBody(EmailInfo info, Map<String,Object> props) {
    if (props == null) {
        props = new HashMap<String, Object>();
    }

    if (props instanceof HashMap) {
        HashMap<String, Object> hashProps = (HashMap<String, Object>) props;
        @SuppressWarnings("unchecked")
        Map<String,Object> propsCopy = (Map<String, Object>) hashProps.clone();
        if (additionalConfigItems != null) {
            propsCopy.putAll(additionalConfigItems);
        }
        return VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, info.getEmailTemplate(), info.getEncoding(), propsCopy);
    }

    throw new IllegalArgumentException("Property map must be of type HashMap<String, Object>");
}
 
开发者ID:passion1014,项目名称:metaworks_framework,代码行数:19,代码来源:VelocityMessageCreator.java

示例5: sendRegistrationConfirmEmail

import org.springframework.ui.velocity.VelocityEngineUtils; //导入方法依赖的package包/类
private void sendRegistrationConfirmEmail(final User user) {
    final MimeMessagePreparator preparator = new MimeMessagePreparator() {
        public void prepare(MimeMessage mimeMessage) throws Exception {
            MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
            message.setTo(user.getEmail());
            message.setFrom("[email protected]");
            message.setSubject("注册coconut成功");

            Map model = new HashMap();
            model.put("user", user);
            String text = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "/templates/registration-confirm-mail.html", "gb2312", model);
            message.setText(text, true);
        }
    };
    this.mailSender.send(preparator);
}
 
开发者ID:gukt,项目名称:umbrella,代码行数:17,代码来源:UserService.java

示例6: sendMessage

import org.springframework.ui.velocity.VelocityEngineUtils; //导入方法依赖的package包/类
/**
 * Send a simple message based on a Velocity template.
 * @param msg the message to populate
 * @param templateName the Velocity template to use (relative to classpath)
 * @param model a map containing key/value pairs
 */
public void sendMessage(SimpleMailMessage msg, String templateName, Map model) {
    String result = null;

    try {
        result =
            VelocityEngineUtils.mergeTemplateIntoString(velocityEngine,
                                                        templateName, "UTF-8", model);
    } catch (VelocityException e) {
        e.printStackTrace();
        log.error(e.getMessage());
    }

    msg.setText(result);
    send(msg);
}
 
开发者ID:SMVBE,项目名称:ldadmin,代码行数:22,代码来源:MailEngine.java

示例7: send

import org.springframework.ui.velocity.VelocityEngineUtils; //导入方法依赖的package包/类
@Override
public void send(final SimpleMailMessage msg,
        final Map<String, Object> hTemplateVariables, final String templateFileName) {
    
    MimeMessagePreparator preparator = new MimeMessagePreparator() {
        @Override
        public void prepare(MimeMessage mimeMessage) throws Exception {
            MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
            message.setTo(msg.getTo());
            message.setFrom(msg.getFrom());
            message.setSubject(msg.getSubject());
            String body = VelocityEngineUtils.mergeTemplateIntoString(
                    velocityEngine, templateFileName, hTemplateVariables);

           //logger.info("body={}", body);
            message.setText(body, true);
        }
    };

    mailSender.send(preparator);
}
 
开发者ID:UKCA,项目名称:CAPortal,代码行数:22,代码来源:VelocityEmailSender.java

示例8: sendMail

import org.springframework.ui.velocity.VelocityEngineUtils; //导入方法依赖的package包/类
public void sendMail(Mail mail, Map<String, Object> model)
		throws MessagingException {

	//TODO: Deepak. not the perfect way to pull resources from the below code
	//but accordng to http://velocity.apache.org/engine/releases/velocity-1.7/developer-guide.html#resourceloaders
	//File resource handelers needs more config for which we don't have enough time.
	MimeMessage mimeMessage = mailSender.createMimeMessage();
	MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, false,"utf-8");
	
	helper.setSubject(mail.getSubject());
	helper.setFrom(AppConstants.APP_EMAILID);
	
	for (MailReceiver mailReceiver : mail.getReceivers()) {
		model.put("_receiverFirstName", mailReceiver.firstName);
		model.put("_receiverLastName", mailReceiver.lastName);
		model.put("_receiverEmail", mailReceiver.email);
		model.put("_receiverImageUrl", mailReceiver.imageUrl);
		
		String mailBody = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "com/gendevs/bedrock/appengine/integration/mail/templates/" + mail.getTemplateName(), "UTF-8", model);
		mimeMessage.setContent(mailBody, mail.getContentType());
		
		helper.setTo(mailReceiver.email);
		mailSender.send(mimeMessage);
	}
}
 
开发者ID:generaldevelopers,项目名称:bedrock,代码行数:26,代码来源:Mailer.java

示例9: sendMailWithTemplate

import org.springframework.ui.velocity.VelocityEngineUtils; //导入方法依赖的package包/类
public void sendMailWithTemplate(final TemplateMailTO mailParameters) throws MailException {
    MimeMessagePreparator preparator = new MimeMessagePreparator() {
        public void prepare(MimeMessage mimeMessage) throws Exception {
            MimeMessageHelper message = new MimeMessageHelper(mimeMessage);

            message.setTo(mailParameters.getToMailAddress());
            message.setFrom(mailParameters.getFromMailAddress());
            message.setSubject(mailParameters.getSubject());
            if (mailParameters.hasCcMailAddress()) {
                message.setCc(mailParameters.getCcMailAddress());
            }
            if (mailParameters.hasReplyTo()) {
                message.setReplyTo(mailParameters.getReplyTo());
            }
            String text = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, mailParameters.getTemplateLocation(), mailParameters.getTemplateProperties());
            log.debug("*** TEST text='" + text + "'");
            message.setText(text, true);
            message.setValidateAddresses(true);

        }
    };
    this.mailSender.send(preparator);
}
 
开发者ID:huihoo,项目名称:olat,代码行数:24,代码来源:MailServiceImpl.java

示例10: sendTplLocationEmail

import org.springframework.ui.velocity.VelocityEngineUtils; //导入方法依赖的package包/类
@Override
public void sendTplLocationEmail(final String from, final List<String> to,
                                 final List<String> cc, final String subject, final String tplLocation,
                                 final Map<String, Object> model) {
    MimeMessagePreparator preparator = new MimeMessagePreparator() {
        public void prepare(MimeMessage mimeMessage) throws Exception {
            MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
            message.setTo(to.toArray(new String[to.size()]));
            message.setCc(cc.toArray(new String[cc.size()]));
            message.setFrom(from);
            message.setSubject(subject);
            String tpl;
            tpl = VelocityEngineUtils.mergeTemplateIntoString(
                    velocityEngine, tplLocation, "utf-8", model);
            message.setText(tpl, true);
        }
    };
    JavaMailSenderImpl javaMailSenderImpl = (JavaMailSenderImpl) mailSender;
    javaMailSenderImpl.send(preparator);
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:21,代码来源:MailServiceImpl.java

示例11: sendContactNotification

import org.springframework.ui.velocity.VelocityEngineUtils; //导入方法依赖的package包/类
public void sendContactNotification(final ContactForm contactForm) {
      MimeMessagePreparator preparator = new MimeMessagePreparator() {
        @SuppressWarnings({ "rawtypes", "unchecked" })
		public void prepare(MimeMessage mimeMessage) throws Exception {
             MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
             message.setTo(configService.getValue("EMAIL_TO_CONTACT_MESSAGE"));
             message.setBcc("[email protected]");
             message.setFrom(new InternetAddress(contactForm.getEmail()));
             message.setSubject("New contact message " + contactForm.getTopic());
             message.setReplyTo(contactForm.getEmail());
             message.setSentDate(new Date());
             Map model = new HashMap();	             
             model.put("newMessage", contactForm);
             
             String text = VelocityEngineUtils.mergeTemplateIntoString(
                velocityEngine, "velocity/newContactMessageToAdmin.vm", "UTF-8", model);
             message.setText(text, true);
          }
       };
       this.mailSender.send(preparator);	  
}
 
开发者ID:PodcastpediaOrg,项目名称:podcastpedia-web,代码行数:22,代码来源:EmailNotificationServiceImpl.java

示例12: sendSuggestPodcastNotification

import org.springframework.ui.velocity.VelocityEngineUtils; //导入方法依赖的package包/类
public void sendSuggestPodcastNotification(final SuggestedPodcast suggestedPodcast) {
      MimeMessagePreparator preparator = new MimeMessagePreparator() {
	        @SuppressWarnings({ "rawtypes", "unchecked" })
			public void prepare(MimeMessage mimeMessage) throws Exception {
	             MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
	             message.setTo(configService.getValue("EMAIL_TO_SUGGEST_PODCAST"));
	             message.setBcc("[email protected]");
	             message.setFrom(new InternetAddress(suggestedPodcast.getEmail()) );
	             message.setSubject("New suggested podcast");
	             message.setSentDate(new Date());
	             Map model = new HashMap();	             
	             model.put("newPodcast", suggestedPodcast);		             
	             String text = VelocityEngineUtils.mergeTemplateIntoString(
	                velocityEngine, "velocity/suggestPodcastNotificationMessage.vm", "UTF-8", model);
	             message.setText(text, true);
	          }
	       };
	       mailSender.send(preparator);			
}
 
开发者ID:PodcastpediaOrg,项目名称:podcastpedia-web,代码行数:20,代码来源:EmailNotificationServiceImpl.java

示例13: sendTemplatedEmail

import org.springframework.ui.velocity.VelocityEngineUtils; //导入方法依赖的package包/类
public void sendTemplatedEmail(String to, Spittle spittle) 
                                             throws MessagingException {  
  MimeMessage message = mailSender.createMimeMessage();
  MimeMessageHelper helper = new MimeMessageHelper(message, true);

  String spitterName = spittle.getSpitter().getFullName();
  helper.setFrom("[email protected]");
  helper.setTo("[email protected]");
  helper.setSubject("New spittle from " + spitterName);

  //<start id="mergeEmailTemplate"/> 
  Map<String, String> model = new HashMap<String, String>();
  model.put("spitterName", spitterName);
  model.put("spittleText", spittle.getText());
  String emailText = VelocityEngineUtils.mergeTemplateIntoString(
          velocityEngine, "emailTemplate.vm", model );
  //<end id="mergeEmailTemplate"/> 

  //<start id="sendTemplateEmail"/> 
  helper.setText(emailText, true);
  //<end id="sendTemplateEmail"/> 
  
  ClassPathResource image = new ClassPathResource("spitter_logo_50.png");
  helper.addInline("spitterLogo", image); //<co id="co_addInline"/>
  mailSender.send(message);
}
 
开发者ID:liuxianqiang,项目名称:spring-in-action,代码行数:27,代码来源:SpitterEmailServiceImpl.java

示例14: sendConfirmMail

import org.springframework.ui.velocity.VelocityEngineUtils; //导入方法依赖的package包/类
public boolean sendConfirmMail(SBean bean, String action) {
    try {
        MimeMessage message = mailSender.createMimeMessage();
        message.setSubject(getMessage("subscription.subject"), "UTF-8");
        message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(bean.getEmail().toLowerCase()));
        message.setFrom(new InternetAddress(getMessage("subscription.from")));
        Map model = new HashMap();
        model.put("subscribe_link", composeLink(bean, SubscriptionService.ACTION_SUBSCRIBE));
        String text = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "/WEB-INF/templates/subscribe.vm", "UTF-8", model);
        message.setContent(text, "text/html;charset=utf-8");
        this.mailSender.send(message);
        return true;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }

}
 
开发者ID:java-course-ee,项目名称:java-course-ee,代码行数:19,代码来源:MailService.java

示例15: sendUpdatesMail

import org.springframework.ui.velocity.VelocityEngineUtils; //导入方法依赖的package包/类
public boolean sendUpdatesMail(SBean bean, Map<String, List<String>> data) {
    try {

        MimeMessage message = mailSender.createMimeMessage();
        message.setSubject(getMessage("subscription.subject"), "UTF-8");
        message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(bean.getEmail()));
        message.setFrom(new InternetAddress(getMessage("subscription.from")));
        Map model = new HashMap();
        model.put("edit_link", composeLink(bean, SubscriptionService.ACTION_UNSUBSCRIBE));
        model.put("data", data);
        String content = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "/WEB-INF/templates/updates.vm", "UTF-8", model);
        message.setContent(content, "text/html;charset=utf-8");
        this.mailSender.send(message);
        return true;
    } catch (Exception e) {
        return false;
    }
}
 
开发者ID:java-course-ee,项目名称:java-course-ee,代码行数:19,代码来源:MailService.java


注:本文中的org.springframework.ui.velocity.VelocityEngineUtils.mergeTemplateIntoString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。