0

我的代码是这样的:

                    <li class="${properties.kcFormSocialAccountListLinkClass!}"><a href="http://localhost:4200/" id="zocial-${p.alias}" class="zocial ${p.providerId}"> <span>Sign in using OTP</span></a></li>
               

问题是,我需要使用 localhost:4200/ 将当前窗口 url 作为查询参数发送。我怎么做 ?该文件是FTL类型。

4

1 回答 1

0

这可以通过使用以下方式访问 Servlet Request 对象来实现:

${springMacroRequestContext.requestUri}

/help如果 ftl 是带有 URL 的页面,它将返回/打印http://www.example.com/help 对象springMacroRequestContextRequestContext类的表示: https ://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/servlet /support/RequestContext.html

但是,我看到您没有使用 Spring MVC 或 Spring Boot,因此恐怕您无法使用它,那么为什么不使用 Javascript 来做呢:

var url = window.location.href;

检查此答案以获取更多选项。

于 2021-04-14T07:05:16.540 回答