Question

I'm passing to velocity template comma separated values and while starting I receive ParseErrorException. How to fix it?

#set ($test=StringUtils.split($filterFieldCSV,","))

    #foreach ( $filterField in $test )
    <!-- process something here -->
#end



Caused by: org.apache.velocity.exception.ParseErrorException: Encountered "StringUtils" at t-50[line 3, column 12] Was expecting one of:
    "[" ...
    "{" ...
    "(" ...
    <WHITESPACE> ...
    <STRING_LITERAL> ...
    "true" ...
    "false" ...
    <INTEGER_LITERAL> ...
    <FLOATING_POINT_LITERAL> ...
    <IDENTIFIER> ...
    "{" ...
    <LOGICAL_NOT> ...
        at org.apache.velocity.Template.process(Template.java:141)  at org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:446)  at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:354)   at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1400)   at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1380)   at org.apache.velocity.app.VelocityEngine.getTemplate(VelocityEngine.java:401)
Was it helpful?

Solution

I simply had to have the following statement:

#set($test=$filterFieldCSV.split(","))

instead of:

#set($test=StringUtils.split($filterFieldCSV,","))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top