Flex Gateway新着情報
Governance新着情報
Monitoring API ManagerFlex Gateway新着情報
Governance新着情報
Monitoring API Manager2.x
Mule 4
3.9
1.1
2.x
1.2
7.x
カスタム文字列補間値を使用して、URL コンポーネントを encodeURIComponent
結果に置き換えます。この関数は、標準コールまたは簡易バージョンを使用してコールできます。
名前 | 説明 |
---|---|
|
|
|
|
次の例では、compose 関数を使用してエンコードされた URL を形成します。最初のパラメーターは 2 つの文字列から成る配列で、これらは URL の一部です。2 つ目のパラメーターは最初のパラメーターの文字列を補間するために使用される urlPath
変数です。
入力内のスペースは出力 URL では %20
にエンコードされます。
%dw 2.0
output application/json
var urlPath = "content folder"
import * from dw::core::URL
---
{ "encodedURL" : compose(["http://examplewebsite.com/", "/page.html"], ["$(urlPath)"]) }
DataWeave
{ "encodedURL" : "http://examplewebsite.com/content%20folder/page.html" }
JSON
この関数を簡易構文を使用してコールすることもできます。その場合は、エンコードする変数を含む文字列をバッククォート (`
) で囲みます。次の例は、簡易構文を使用して前の例と同じ結果を得る方法を示しています。
%dw 2.0
output application/json
var urlPath = "content folder"
import * from dw::core::URL
---
{ "encodedURL" : compose `http://examplewebsite.com/$(urlPath)/page.html`}
DataWeave
{ "encodedURL" : "http://examplewebsite.com/content%20folder/page.html" }
JSON