java - SpEL expression to utilize "contains()" string method -


i trying utilize string.contains() in order dynamically create value field based upon name of file stored in jobexecutioncontext. key/value (file=>nameoffile.txt) pair exists in context because utilizing in other places.

i trying folllowing spel expression:

<property name="subject" value="#{((string)jobexecutioncontext['file']).contains('monk') ? 'monkey' : 'banana'} kind of file" /> 

however i'm getting error:

expression parsing failed; nested exception org.springframework.expression.spel.spelparseexception: el1043e:(pos 9): unexpected token.  expected 'rparen())' 'identifier' 

the exception because "(string)",you can this:

<util:map id="fruit">     <entry key="banana" value="#{89.7}"/>     <entry key="apple" value="efg"/>     <entry key="orange" value="lmn"/> </util:map> <bean id="hello" class="com.choiwan.hello">     <property name="name" value="#{(fruit['banana']+'').contains('89')?'monkey':'banana'} kind of file"/> </bean> 

Comments

Popular posts from this blog

html - Difficulties with background-image property -

visual studio code - What does the isShellCommand property actually do and how should you use it? -

ios - Segue not passing data between ViewControllers -