I want to print both key and value in ForEach. I am able to get the Keyset but not individual key.
<set-variable variableName="fileContents" value="#[message.payload]" />
<foreach collection="#[message.payload]">
<logger message="#[fileContents.keySet()]" level="INFO" doc:name="Logger"/>
<logger message="#[message:payload]" level="INFO" doc:name="Logger"/>
</foreach>
If fileContents is a Map, then you should use collections=#[payload.entrySet()]
. That way within the foreach
you can do #[payload.key]
and #[payload.value]
(because the payload in each step will be an Entry).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.