jsp - Using variable in jstl "key" of <fmt:message key="<%=customFieldData%>" /> -
in jsp page there labels coming controller in spring mvc. trying use properties file show different values labels. here jsp code
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> <fmt:bundle basename="main.resources.abc_messages"> <% if (request.getattribute("customfields") != null) { string line = request.getattribute("customfields").tostring(); line = line.subsequence(1, line.length() - 1).tostring(); string[] data = splitlineintoarray(line, ","); (int = 0; < data.length; i++) { string field = data[i]; string[] customfielddata = splitlineintoarray(field, "="); %> <div class="row"> <div class="left"> <fmt:message key="<%=customfielddata[0]%>"/> </div> <div class="right"> <input type="text" type="customfield" value="<%=customfielddata[1]%>" id="customfield" class="inputfixed" disabled="true" /> </div> <div class="clear"></div> </div> <% } } %> </fmt:bundle> i have put properties file abc_messages.properties in classpath. when use key="abc" , properties file has abc=xyz value xyz. on using variable required here ???. getting output
??? color??? : green ??? font ??? : arial abc_messages.properties file
color=main color font=main font
the issue space getting customfields data. " color " string getting in properties file there "color". gave ??? color ??? . should have trim() customfielddata before putting in key
Comments
Post a Comment