當前位置: 首頁>>代碼示例>>Java>>正文


Java Context.setVariable方法代碼示例

本文整理匯總了Java中org.thymeleaf.context.Context.setVariable方法的典型用法代碼示例。如果您正苦於以下問題:Java Context.setVariable方法的具體用法?Java Context.setVariable怎麽用?Java Context.setVariable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.thymeleaf.context.Context的用法示例。


在下文中一共展示了Context.setVariable方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getMembershipEmailHtml

import org.thymeleaf.context.Context; //導入方法依賴的package包/類
public String getMembershipEmailHtml(User user) {
    DateTimeFormatter formatter =
            DateTimeFormatter.ISO_LOCAL_DATE
                    .withZone(ZoneId.of("Europe/Tallinn"));
    Member member = user.getMemberOrThrow();
    String memberDate = formatter.format(member.getCreatedDate());

    Context ctx = new Context();
    ctx.setVariable("memberNumber", member.getMemberNumber());
    ctx.setVariable("firstName", user.getFirstName());
    ctx.setVariable("lastName", user.getLastName());
    ctx.setVariable("memberDate", memberDate);
    ctx.setLocale(localeResolver.resolveLocale(request));

    String htmlContent = templateEngine.process("membership", ctx);
    return htmlContent;
}
 
開發者ID:TulevaEE,項目名稱:onboarding-service,代碼行數:18,代碼來源:EmailContentService.java

示例2: sendEmailWithVerificationLinkAndLang

import org.thymeleaf.context.Context; //導入方法依賴的package包/類
@Override
public void sendEmailWithVerificationLinkAndLang(String xForwardedProto, String xForwardedHost, int xForwardedPort, String email, String emailToken, String recipientFullName, String language) {
    Assert.hasText(emailToken, "emailToken must have text");
    Assert.hasText(email, "email must have text");
    Assert.hasText(recipientFullName, "recipientFullName must have text");
    final String fragment = emailSenderProperties.getPpUiVerificationEmailTokenArgName() + "=" + emailToken;

    final String verificationUrl = toPPUIVerificationUri(xForwardedProto, xForwardedHost, xForwardedPort, fragment);
    final Context ctx = new Context();
    ctx.setVariable(PARAM_RECIPIENT_NAME, recipientFullName);
    ctx.setVariable(PARAM_LINK_URL, verificationUrl);
    ctx.setVariable(PARAM_BRAND, emailSenderProperties.getBrand());
    if (language == null || language.trim().isEmpty()) {
        language = "en";
    }
    Locale locale = new Locale(language);
    ctx.setLocale(locale);// set locale to support multi-language
    sendEmail(ctx, email,
            PROP_EMAIL_VERIFICATION_LINK_SUBJECT,
            TEMPLATE_VERIFICATION_LINK_EMAIL,
            PROP_EMAIL_FROM_ADDRESS,
            PROP_EMAIL_FROM_PERSONAL,
            locale);
}
 
開發者ID:bhits,項目名稱:patient-user-api,代碼行數:25,代碼來源:EmailSenderImpl.java

示例3: sendForgotPasswordEmail

import org.thymeleaf.context.Context; //導入方法依賴的package包/類
/**
 * <p>sendForgotPasswordEmail.</p>
 *
 * @param email a {@link java.lang.String} object.
 * @param resetPwdURL a {@link java.lang.String} object.
 */
protected void sendForgotPasswordEmail(String email, String resetPwdURL) {
	try {

		// Prepare the evaluation context
		final Context ctx = new Context(Locale.ENGLISH);
		ctx.setVariable("resetPwdURL", resetPwdURL);

		// Create the HTML body using Thymeleaf
		final String htmlContent = this.templateEngine.process("forgot-password-email", ctx);

		emailService.sendEmail(email, getMessage(LABEL_PASSWORD_RESET_EMAIL_SUBJECT), htmlContent);
	} catch (SecuredAppException e) {
		log.error(e.getMessage());
	}
}
 
開發者ID:rajadilipkolli,項目名稱:springsecuredthymeleafapp,代碼行數:22,代碼來源:UserAuthController.java

示例4: sendCreationEmail

import org.thymeleaf.context.Context; //導入方法依賴的package包/類
@Async
public void sendCreationEmail(User user, String baseUrl) {
    log.debug("Sending creation e-mail to '{}'", user.getEmail());
    Locale locale = Locale.forLanguageTag(user.getLangKey());
    Context context = new Context(locale);
    context.setVariable(USER, user);
    context.setVariable(BASE_URL, baseUrl);
    String content = templateEngine.process("creationEmail", context);
    String subject = messageSource.getMessage("email.activation.title", null, locale);
    sendEmail(user.getEmail(), subject, content, false, true);
}
 
開發者ID:klask-io,項目名稱:klask-io,代碼行數:12,代碼來源:MailService.java

示例5: sendCreationEmail

import org.thymeleaf.context.Context; //導入方法依賴的package包/類
@Async
public void sendCreationEmail(User user) {
    log.debug("Sending creation e-mail to '{}'", user.getEmail());
    Locale locale = Locale.forLanguageTag(user.getLangKey());
    Context context = new Context(locale);
    context.setVariable(USER, user);
    context.setVariable(BASE_URL, jHipsterProperties.getMail().getBaseUrl());
    String content = templateEngine.process("creationEmail", context);
    String subject = messageSource.getMessage("email.activation.title", null, locale);
    sendEmail(user.getEmail(), subject, content, false, true);
}
 
開發者ID:mraible,項目名稱:devoxxus-jhipster-microservices-demo,代碼行數:12,代碼來源:MailService.java

示例6: sendEmailFromTemplate

import org.thymeleaf.context.Context; //導入方法依賴的package包/類
@Async
public void sendEmailFromTemplate(User user, String templateName, String titleKey) {
    Locale locale = Locale.forLanguageTag(user.getLangKey());
    Context context = new Context(locale);
    context.setVariable(USER, user);
    context.setVariable(BASE_URL, jHipsterProperties.getMail().getBaseUrl());
    String content = templateEngine.process(templateName, context);
    String subject = messageSource.getMessage(titleKey, null, locale);
    sendEmail(user.getEmail(), subject, content, false, true);

}
 
開發者ID:oktadeveloper,項目名稱:jhipster-microservices-example,代碼行數:12,代碼來源:MailService.java

示例7: sendActivationEmail

import org.thymeleaf.context.Context; //導入方法依賴的package包/類
@Async
    public void sendActivationEmail(User user, String baseUrl) {
        log.debug("Sending activation e-mail to '{}'", user.getEmail());
        Locale locale = Locale.forLanguageTag(user.getLangKey());
        Context context = new Context(locale);
        context.setVariable("user", user);
        context.setVariable("baseUrl", baseUrl);
        String content = templateEngine.process("activationEmail", context);
        String subject = messageSource.getMessage("email.activation.title", null, locale);
//        sendEmail(user.getEmail(), subject, content, false, true);
        sendMailToQueue(user.getEmail(), subject, content, false, true);
    }
 
開發者ID:ugouku,項目名稱:shoucang,代碼行數:13,代碼來源:MailService.java

示例8: sendTemplateMail

import org.thymeleaf.context.Context; //導入方法依賴的package包/類
/**
 * 測試 使用模板發送郵件
 */
@Test
public void sendTemplateMail() {
    //創建郵件正文
    Context context = new Context();
    context.setVariable("id", "77451733");
    String emailContent = templateEngine.process("emailTemplate", context);

    mailService.sendHtmlMail("[email protected]", "test mail", emailContent);
}
 
開發者ID:jeikerxiao,項目名稱:SpringBootStudy,代碼行數:13,代碼來源:MailServiceTest.java

示例9: sendEmailFromTemplate

import org.thymeleaf.context.Context; //導入方法依賴的package包/類
@Async
public void sendEmailFromTemplate(User user, String templateName, String titleKey) {
    Locale locale = Locale.forLanguageTag(user.getLangKey());
    Context context = new Context(locale);
    context.setVariable(USER, user);
    context.setVariable(BASE_URL, baseUrlValue);
    String content = templateEngine.process(templateName, context);
    sendEmail(user.getEmail(), "sample title", content, false, true);

}
 
開發者ID:megadotnet,項目名稱:SpringBootDemoApp,代碼行數:11,代碼來源:MailService.java

示例10: sendPasswordResetMail

import org.thymeleaf.context.Context; //導入方法依賴的package包/類
@Async
    public void sendPasswordResetMail(User user, String baseUrl) {
        log.debug("Sending password reset e-mail to '{}'", user.getEmail());
        Locale locale = Locale.forLanguageTag(user.getLangKey());
        Context context = new Context(locale);
        context.setVariable("user", user);
        context.setVariable("baseUrl", baseUrl);
        String content = templateEngine.process("passwordResetEmail", context);
        String subject = messageSource.getMessage("email.reset.title", null, locale);
//        sendEmail(user.getEmail(), subject, content, false, true);
        sendMailToQueue(user.getEmail(), subject, content, false, true);
    }
 
開發者ID:ugouku,項目名稱:shoucang,代碼行數:13,代碼來源:MailService.java

示例11: sendPasswordResetMail

import org.thymeleaf.context.Context; //導入方法依賴的package包/類
@Async
public void sendPasswordResetMail(User user) {
    log.debug("Sending password reset e-mail to '{}'", user.getEmail());
    Locale locale = Locale.forLanguageTag(user.getLangKey());
    Context context = new Context(locale);
    context.setVariable(USER, user);
    context.setVariable(BASE_URL, jHipsterProperties.getMail().getBaseUrl());
    String content = templateEngine.process("passwordResetEmail", context);
    String subject = messageSource.getMessage("email.reset.title", null, locale);
    sendEmail(user.getEmail(), subject, content, false, true);
}
 
開發者ID:mraible,項目名稱:devoxxus-jhipster-microservices-demo,代碼行數:12,代碼來源:MailService.java

示例12: sendTemplateMail

import org.thymeleaf.context.Context; //導入方法依賴的package包/類
/**
 * 發送模版郵件
 * @param sender
 * @param sendto
 * @param templateName
 * @param o
 */
@Async
public void sendTemplateMail(String sender, String sendto,String title, String templateName,Object o) {

    log.info("開始給"+sendto+"發送郵件");
    MimeMessage message = mailSender.createMimeMessage();
    try {
        //true表示需要創建一個multipart message html內容
        MimeMessageHelper helper = new MimeMessageHelper(message, true);
        helper.setFrom(sender);
        helper.setTo(sendto);
        helper.setSubject(title);

        Context context = new Context();
        context.setVariable("title",title);
        context.setVariables(StringUtils.beanToMap(o));
        //獲取模板html代碼
        String content = templateEngine.process(templateName, context);

        helper.setText(content, true);

        mailSender.send(message);
        log.info("給"+sendto+"發送郵件成功");
    }catch (Exception e){
        e.printStackTrace();
    }
}
 
開發者ID:Exrick,項目名稱:xpay,代碼行數:34,代碼來源:EmailUtils.java

示例13: sendSocialRegistrationValidationEmail

import org.thymeleaf.context.Context; //導入方法依賴的package包/類
@Async
public void sendSocialRegistrationValidationEmail(User user, String provider) {
    log.debug("Sending social registration validation e-mail to '{}'", user.getEmail());
    Locale locale = Locale.forLanguageTag(user.getLangKey());
    Context context = new Context(locale);
    context.setVariable(USER, user);
    context.setVariable("provider", StringUtils.capitalize(provider));
    String content = templateEngine.process("socialRegistrationValidationEmail", context);
    String subject = messageSource.getMessage("email.social.registration.title", null, locale);
    sendEmail(user.getEmail(), subject, content, false, true);
}
 
開發者ID:quanticc,項目名稱:sentry,代碼行數:12,代碼來源:MailService.java

示例14: sendAlert

import org.thymeleaf.context.Context; //導入方法依賴的package包/類
public boolean sendAlert(AlertEntry alertEntry, List<String> emails, String mailTemplate){
    logger.debug("Sending alert  e-mail to '{}'", emails.toString());
    Locale locale = Locale.getDefault();
    Context context = new Context(locale);
    context.setVariable("alert", alertEntry);
    String content = templateEngine.process(mailTemplate, context);
    return sendEmail(mailFromBpo, emails, "New Application ticket has been created", content);
}
 
開發者ID:Romeh,項目名稱:spring-boot-ignite,代碼行數:9,代碼來源:MailService.java

示例15: getContext

import org.thymeleaf.context.Context; //導入方法依賴的package包/類
@Override
public IContext getContext() {
	final Context ctx = new Context();
	ctx.setVariable("now", new Date());
	ctx.setVariable("name", "Name Surname");
	ctx.setVariable("hobbies", Arrays.asList("Cinema", "Sports", "Music"));

	return ctx;
}
 
開發者ID:mychalvlcek,項目名稱:spring-rest-skeleton,代碼行數:10,代碼來源:ExampleMailPreparator.java


注:本文中的org.thymeleaf.context.Context.setVariable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。