title: How to pass an array into SpEL expression within JSP
body: <p>Am trying to use SpEL to call method on a service class, eg:</p>
  
  <pre><code>&lt;spring:eval expression="@securityService.hasPermissionToAllArray('${data.regionsArray}')" /&gt;
  </code></pre>
  
  <p>Where data is an object in the request scope, and it has a method as follows:</p>
  
  <pre><code>public String[] getRegionsArray() {
      List&lt;String&gt; regions = new ArrayList&lt;String&gt;();
      regions.add("aaa");
      regions.add("bbb");
      return regions.toArray(new String[]{});
  }
  </code></pre>
  
  <p>And the securityService has this method defined:</p>
  
  <pre><code>public boolean hasPermissionToAllArray(String []regions) {
      logger.warn("size={} regions='{}' regions[0]={}", regions.length, regions, regions[0]);
      return true;
  }
  </code></pre>
  
  <p>Here is the output from the logger:</p>
  
  <pre><code>size=1 regions='[[Ljava.lang.String;@13299648]' regions[0]=[Ljava.lang.String;@13299648
  </code></pre>
  
  <p>So it seems like the returned value from getRegionsArray() is being converted into a string, and then passed to hasPermissionToAllArray() as the first element of the array.</p>
  
  <p>If I convert the array value to a string as follows, it works:</p>
  
  <pre><code>        &lt;c:set var="r" value="${fn:join(data.regionsArray, ',')}" /&gt;
          &lt;spring:eval expression="@securityService.hasPermissionToAllArray('${r}')" /&gt;
  </code></pre>
  
  <p>Here is the log output:</p>
  
  <pre><code>size=2 regions='[aaa, bbb]' regions[0]=aaa
  </code></pre>
  
  <p>But, obviously this is not ideal.</p>
  
  <p>NOTE: have tried using List's instead of arrays, with the same outcome.</p>