如何使用thymeleaf设置属性的值?

bwitn5fc  于 2021-06-29  发布在  Java
关注(0)|答案(0)|浏览(139)

我正在处理一个电子邮件模板,它将接收一个confirmationurl参数,该参数位于名为sendverificationtoken的auth方法中。
html格式

<p>Use <a th:attr="href=#{confirmationUrl}" target="_blank" rel="noopener">this link</a> to activate your account now.&nbsp;</span></p>

sendverificationtoken方法

public void sendVerificationToken(User user) {
    String token = jwtTokenService.genEmailVerificationToken(user.getId());
    logger.info("Sending verification token to user. user={} email={} token={}",
            user.getId(), user.getEmail(), token);
    String confirmationUrl = null;
    try {
        confirmationUrl = new URIBuilder(verifyEmailUrl)
                .addParameter(VERIFY_EMAIL_ENDPOINT_PARAM, token)
                .build().toString();
    }

    catch (URISyntaxException e) {
        logger.error("URL stored as redirect url for verify email is not valid.");
        throw ErrorFactory.serverError("Error");
    }
    emailService.sendAccountConfirmationEmail(user.getEmail(), confirmationUrl);
}

如何使用thymeleaf正确地将参数从方法中获取到html模板中?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题