1

I needs to split string with value $$ in spring context xml file, I have tried below things, but no luck :( Anyone can help please?

In java it's working something like this,

public static void main(String[] args) {
        System.err.println("localhost$$8080".split("\\$\\$")[1]);
    }

My tries

  • <constructor-arg name="port" value="#{'#{config.getNode()}'.split('\\$\\$')[1]}" />
  • <constructor-arg name="port" value="#{'#{config.getNode()}'.split('$$')[1]}" />
  • <constructor-arg name="port" value="#{'#{config.getNode()}'.split('\$\$')[1]}" />
  • <constructor-arg name="port" value="#{'#{config.getNode()}'.split('\\u0024\\u0024')[1]}" />

NOTE : Please assume that config.getNode() will give value "localhost$$8080".

Vishal Zanzrukia
  • 4,902
  • 4
  • 38
  • 82

2 Answers2

1

Try something like this:

@Value("#{config.getNode().split('\\$\\$')[1]}")
private String port;

or in the XML:

<constructor-arg name="port" value="#{config.getNode().split('\\$\\$')[1]}" />
Gabe
  • 431
  • 3
  • 11
0

It should be like below:

 <constructor-arg name="port" 
      value="#{config.getNode().split('\\u0024\\u0024')[1]}" />
Vasu
  • 21,832
  • 11
  • 51
  • 67