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
:
- split in 2 parts on whitespace (what if there more whitespaces?)
- show 2nd part of split in uppercased flavor.
- show comma , space.
- show 1st part of split.
this doable jstl functions.
<c:set var="parts" value="${fn:split(bean.name, ' ')}" />
${fn:touppercase(parts[1])}
,
${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
Post a Comment