Reputation: 4973
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".
Upvotes: 1
Views: 2181
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
Reputation: 22442
It should be like below:
<constructor-arg name="port"
value="#{config.getNode().split('\\u0024\\u0024')[1]}" />
Upvotes: 0