0

I am trying to do something like this:

#{ systemProperties['mySystemProperty'] == 'ABC' ? 'pathB' : 'pathC'} 

in the path to a resource in the spring context.

(See also my question: Use bean value as property in spring context)

But although mySystemProperty is definitely 'ABC' 'pathB' is never used.

Do I have to do the String comparison in another way?

Thanks

UPDATE

I found out that the original problem is not the String comparison.

I tried:

<import resource="#{'A' == 'A' ? 'pathA' : 'pathB'}/myConfig.xml" />

-> The config is never read. This line will be totally ignored. It does not matter if pathA or pathB exists.... This line is ignored.

I also tried:

<import resource="#{true ? 'pathA' : 'pathB'}/myConfig.xml" />

And the outcome is the same. The whole line is ignored. No exceptions when the file is not found, no exceptions when the file contains nonsense. The whole line is simply ignored.... How is that possible?

UPDATE

I am using spring profiles instead now, see the last update of the question in Use bean value as property in spring context.

That's more appropriote for me, but the original problem hasn't been solved: A resource import does not work when SpEL is used.

Community
  • 1
  • 1
Nina
  • 681
  • 1
  • 10
  • 27
  • Are you trying to compare an exact string or a substring? What happens if you just inject the property as-is and examine it? – chrylis -cautiouslyoptimistic- Sep 14 '16 at 07:39
  • Mmh... it's weird... I tried with the result: SAXParseException: Content is not allowed in prolog. – Nina Sep 14 '16 at 08:16
  • i tried it by SPEL parser `System.out.println(parser.parseExpression("'ABC'=='ABC'?'1':'2'").getValue(String.class));`, and it worked fine with `==`. So i think your `systemProperties['mySystemProperty']` should be problem. – Minh Sep 14 '16 at 08:53

1 Answers1

0

If you tried to "==" replaced with "EQ"

Roman.Luo
  • 63
  • 5