EL 表达式中使用自定义函数
程序员文章站
2022-06-08 08:37:45
...
一、Java
package test.utils.ctag; public class CustomTags { public static boolean equals(String s1,String s2){ if(s1==s2) return true; if(s1!=null) return s1.equals(s2); return false; } }
二、TLD
<?xml version="1.0" encoding="UTF-8" ?> <taglib xmlns="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 web-jsptaglibrary_2_0.xsd" version="2.0"> <tlib-version>1.0</tlib-version> <jsp-version>2.0</jsp-version> <short-name>f</short-name> <function> <name>equals</name> <function-class>test.utils.ctag.CustomTags</function-class> <function-signature>boolean equals( java.lang.String, java.lang.String )</function-signature> </function> </taglib>
三、web.xml
<jsp-config> <taglib> <taglib-uri>/functions</taglib-uri> <taglib-location>/WEB-INF/classes/functions.tld</taglib-location> </taglib> </jsp-config>
四、Jsp
<%@ taglib prefix="f" uri="/functions" %>
${f:equals("Hello","Hello")}<br/> ${f:equals("Hello","World")}<br/> ${f:equals(null,"World")}
上一篇: 关于PHP中的自增、自减操作的奥秘
下一篇: flex发送QQ表情
推荐阅读
-
Oracle中instr函数使用方法
-
python中lambda函数 list comprehension 和 zip函数使用指南
-
JS中内嵌函数中this关键字的使用(报错)
-
如何使用IE8中浏览器自定义功能
-
PHP函数preg_match_all正则表达式的基本使用详细解析
-
在Python中使用itertools模块中的组合函数的教程
-
浅析PHP中call user func()函数及如何使用call user func调用自定义函数
-
awk正则表达式和内置函数的使用方法实例详解
-
Python中函数的多种格式和使用实例及小技巧
-
python中datetime模块中strftime/strptime函数的使用