jstl split function

前端 未结 1 1689
死守一世寂寞
死守一世寂寞 2020-12-22 06:16

I wanted to split a given string using jstl 1.2 eg:

Bean thesis.url contains \"http:website1.com : http:website2.com\"
which needs to be splited into
http:we         


        
1条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-22 06:58

    fn:split will split your string on any of the delimiter characters, so in your case both space and :. The solution is to do a fn:replace first:

    
    
    

    Make sure to replace the separator with a character that is not present in your string, or else you will run into the same problem. Now you can use fn:split(urls, '|'), but it would be easier to use :

    
      ${url}
    
    

    A better solution would be to simply do the work at the back end of your application and pass a list of strings to the front end.

    0 讨论(0)
提交回复
热议问题