PingFederate和Velocity Variable $ client_id

问题描述 投票:0回答:1

变量$ client_id由服务器在运行时生成。它是来自pingfederate的Oauth客户端ID。我想用一个简单的速度来改变我的html中的这个变量if if如下所示:

<!--Checking for $client_id and setting.  Server setting is Oauthclient1-->
#if($client_id.ne("OauthClient2"))
#set ($client_id = "something")
#end

然而,它不会设置,它保持从服务器来的。

apache variables velocity pingfederate
1个回答
0
投票

我不知道$client_id包含哪种对象,但如果它是一个字符串,你应该写:

#if($client_id != "OauthClient2")
  #set ($client_id = "something")
#end

或者,如果它是使用toString()方法的对象:

#if("$client_id" != "OauthClient2")
  #set ($client_id = "something")
#end

如果您需要,可以找出它包含的内容,您可以:

<!--Checking for $client_id and setting.  Server setting is Oauthclient1-->
<!-- client_id is a $client_id.class.name -->

也许你还应该检查$client_id是否为空:

#if (!$client_id)
    Error: $client_id is null
#end
© www.soinside.com 2019 - 2024. All rights reserved.