Home > Net >  How to generate string by joining ArrayList of Strings in spel?
How to generate string by joining ArrayList of Strings in spel?

Time:03-16

I want to form a new string from ArrayList of Strings with a particular delimiter using spel.

list = ["a", "b", "c"]

I want to make a String s = "a,b,c" from above list.

I tried many expressions such as StringUtils.join(list, ','), list.stream().collect(Collectors.joining(',')), etc. but every time I'm getting an error

EL1008E: Property or field 'StringUtils' cannot be found on object of type 'java.util.LinkedHashMap' - maybe not public or not valid?

Is there any way to do this in spel?

CodePudding user response:

You can use this instead

String lst[] = new String[]{"a","b","c"};
System.out.println(String.join(",",lst)); //here output will be a,b,c

CodePudding user response:

If StringUtils.join is a static method, you need T(com.my.StringUtils).join(...) (need full class name too).

  • Related