简体   繁体   中英

How to format get param by split on ^ in jsp by using jslt tag or java

I want to format string which come from url its physicianName in jsp.

This physicianName has string HL7 Format of Referring doctor name => Family Name^Given Name^Middle Name^Prefix^Suffix to Prefix Family Name, Given Name Middle Name.

    <c:set var="phy_name" scope="application"
            value="${param.physicianName}" />

//@@todo formatting to Prefix Family Name, Given Name Middle Name.

This might be simple but I am new to jsp.

It would be great if anyone can give other solution by jsp (<% %>) tag with java code.

Thanks in advance

to replace ^ with a (space), you could do something like this :

<c:set var="phy_name" value="${fn:replace(param.physicianName,'^', ' ')}" />

To exactly format the name in the following way :

 Prefix Family Name, Given Name Middle Name.

you can just use scriptlet tag and code in java, something like this :

<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>


<%
  String tmp[] =  param.physicianName.split(^);
  String formatedPhyName = tmp[3]+" "+tmp[0]+", "+tmp[1]+" "+tmp[2];
%>
<p>Phy name : ${formatedPhyName}</p>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM