Horizontal slot
With TLD files, we can customize a method label for use in the page, and the directory is usually placed in the TLDs folder below the Web-inf:
Introduction to an example of a TLD tag file directly on the JSP:
<% @ taglib Prefix = " FNS " URI = " /web-inf/tlds/fns.tld " %>
Fns.tld in the following:
<?XML version= "1.0" encoding= "UTF-8"?><taglibxmlns= "HTTP://JAVA.SUN.COM/XML/NS/J2EE"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation= "Http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"version= "2.0"> <Description>JSTL 1.1 Functions Library</Description> <Display-name>JSTL functions Sys</Display-name> <tlib-version>1.1</tlib-version> <Short-name>Fns</Short-name> <URI>Http://java.sun.com/jsp/jstl/functionss</URI><!--dictutils - <function> <Description>Get Dictionary Tags</Description> <name>Getdictlabel</name> <Function-class>Com.jeeplus.modules.sys.utils.DictUtils</Function-class> <function-signature>Java.lang.String Getdictlabel (java.lang.String, java.lang.String, java.lang.String)</function-signature> <Example>${fns:getdictlabel (value, type, defaultvalue)}</Example> </function> <function> <Description>Get dictionary labels (multiple)</Description> <name>Getdictlabels</name> <Function-class>Com.jeeplus.modules.sys.utils.DictUtils</Function-class> <function-signature>Java.lang.String getdictlabels (java.lang.String, java.lang.String, java.lang.String)</function-signature> <Example>${fns:getdictlabels (values, type, defaultvalue)}</Example> </function> <function> <Description>Get dictionary value</Description> <name>Getdictvalue</name> <Function-class>Com.jeeplus.modules.sys.utils.DictUtils</Function-class> <function-signature>Java.lang.String Getdictvalue (java.lang.String, java.lang.String, java.lang.String)</function-signature> <Example>${fns:getdictvalue (label, type, defaultvalue)}</Example> </function>
Note:
Function-class is the classpath of the entity of the method,
Function-signature is the method name of the method, and this method must be a static method.
Example is an example of how to use
Background:
Public Staticstring Getdictlabel (string value, String type, string defaultvalue) {if(Stringutils.isnotblank (type) &&Stringutils.isnotblank (value)) { for(Dict dict:getdictlist (type)) {if(Type.equals (Dict.gettype ()) &&value.equals (Dict.getvalue ())) { returnDict.getlabel (); } } } returnDefaultValue; } Public Staticstring Getdictlabels (String values, String type, string defaultvalue) {if(Stringutils.isnotblank (type) &&Stringutils.isnotblank (values)) {List<String> valueList =lists.newarraylist (); for(String Value:StringUtils.split (values, ",") {valuelist.add (Getdictlabel (value, type, defaultvalue)); } returnStringutils.join (ValueList, ","); } returnDefaultValue; } Public Staticstring Getdictvalue (String label, String type, String Defaultlabel) {if(Stringutils.isnotblank (type) &&Stringutils.isnotblank (label)) { for(Dict dict:getdictlist (type)) {if(Type.equals (Dict.gettype ()) &&label.equals (Dict.getlabel ())) { returnDict.getvalue (); } } } returnDefaultlabel; }
Used in JSP pages:
< TD > ${fns:getdictlabel (preparationmanage.preparationmode, ' samplingmode ', ')}
</ TD >
JSP custom TLD Method labels