Spring integration expression map access with dot notation

拜拜、爱过 提交于 2019-12-12 22:42:12

问题


Normally in Spring EL you access a map entry by its key using the key in square brackets. If the payload of a spring integration message is a java.util.Map, then

payload['mykey'] 

gives you the value of the entry having the String 'my-key' as key.

When using the standard Spring EL setup, e.g. in a unit test, that is the only way to work with the map. However, in expressions used by Spring integration flows I can use the dot notation for map access. This works:

payload.mykey

I want to be able to use the same Spring EL expressions both in unit tests and route definitions. What makes the dot notation possible in Spring integration? Do I have to apply some special option to the EL parser?


回答1:


I found the answer at Map for spring expression language. I need to add a http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/context/expression/MapAccessor.html to the evaluation context.



来源:https://stackoverflow.com/questions/45512177/spring-integration-expression-map-access-with-dot-notation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!