EL自定义函数
来源:互联网 发布:dpp软件下载 编辑:程序博客网 时间:2024/05/22 13:18
如果已有的el函数不能满足项目要求,可以开发出自己定义的EL函数。
1 写一个普通的java类,该类必须是public,且java方法必须是静态方法
package com.tag;
public class CustomFun {
public static boolean matches(String s){
return s.equals("wangli");
}
}
2 在TLD文件中配置EL自定义函数
<?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">
<description>A tag library exercising SimpleTag handlers.</description>
<tlib-version>1.0</tlib-version>
<uri>http://shun.com/customfun</uri>
<function>
<name>matches</name>
<function-class>com.tag.CustomFun</function-class>
<function-signature>java.lang.Boolean matches(java.lang.String)</function-signature>
</function>
</taglib>
<uri> 必须是唯一滴。<name>指定使用EL自定义函数时的名称 ${customfun:matches}
3 页面使用el自定义函数
<%@ taglib uri="http://shun.com/customfun" prefix="customfun"%>
${customfun:matches("wangli") }
会看到输出为true
或者 在web.xml中添加
<jsp-config>
<taglib>
<taglib-uri>/tags/customfun</taglib-uri>
<taglib-location>/WEB-INF/tld/customfun.tld</taglib-location>
</taglib>
</jsp-config>
修改jsp页面
<%@ taglib uri="/tags/customfun" prefix="customfun"%>
${customfun:matches("wangli") }
0 0
- 如何自定义EL函数
- EL自定义函数
- el自定义函数
- JSP自定义EL函数
- EL自定义函数
- 自定义EL函数
- EL表达式-自定义函数
- EL表达式-自定义函数
- 自定义el函数
- EL自定义函数
- 自定义EL函数
- EL自定义函数
- EL自定义函数
- 自定义EL函数
- 自定义EL函数
- EL表达式-自定义函数
- 自定义EL函数
- 自定义el函数
- 身份证验证
- 修改Zend Coding 与DW Cs6结合后的快捷键。
- 关于duilib中的list的扩展探索
- log4net使用手册
- 利用中间缓存变量机制
- EL自定义函数
- java 中的printStackTrace()方法
- c语言把将整数倒置1234变成4321
- 爬取ucas获取新生信息第三版Python
- 解析目标文件
- 打印三角形
- DirectX游戏编程基础教程
- zoj 1331 Perfect Cubes
- 小米口碑式营销的7条内部铁规