java - How to format output in JSTL -


i've got span this

<span>${bean.name}</span> 

and returns john brown

how can format shows brown, john in jstl?

so, point, want apply following modifications on string:

  1. split in 2 parts on whitespace (what if there more whitespaces?)
  2. show 2nd part of split in uppercased flavor.
  3. show comma , space.
  4. show 1st part of split.

this doable jstl functions.

  1. <c:set var="parts" value="${fn:split(bean.name, ' ')}" />
  2. ${fn:touppercase(parts[1])}
  3. ,
  4. ${parts[0]}

summarized:

<c:set var="parts" value="${fn:split(bean.name, ' ')}" /> ${fn:touppercase(parts[1])}, ${parts[0]} 

you've problem when name contains more 1 space.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -