Vishal Zanzrukia
Vishal Zanzrukia

Reputation: 4973

Split String with Spring EL

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

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

Upvotes: 1

Views: 2181

Answers (2)

Gabe
Gabe

Reputation: 441

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]}" />

Upvotes: 1

Vasu
Vasu

Reputation: 22442

It should be like below:

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

Upvotes: 0

Related Questions