自定义el函数
来源:互联网 发布:js遍历元素下所有节点 编辑:程序博客网 时间:2024/06/04 01:13
1.编写Java类注意方法必须为static
package cn.syq.tag;
public class HelloWord {
public static String hello(){
return "hello";
}
public static String word(int a,Integer b){
return "word"+a+"_"+b;
}
}
2.在WEB-INF(子)目录下创建xxx.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 http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd" version="2.0">
<!-- 版本和uri必须写 -->
<tlib-version>1.0</tlib-version>
<uri>/eltag</uri>
<!-- 定义一个函数 -->
<function>
<name>hello</name>
<function-class>cn.syq.tag.HelloWord</function-class>
<function-signature>
java.lang.String hello()
</function-signature>
</function>
<!-- 定义一个函数 -->
<function>
<name>word</name>
<function-class>cn.syq.tag.HelloWord</function-class>
<function-signature>
java.lang.String word(int,java.lang.Integer)
</function-signature>
</function>
</taglib>
3.在jsp文件中引入如下
<%@ taglib uri="/eltag" prefix="eg"%>
<input type="text" value="${eg:hello()}" />
package cn.syq.tag;
public class HelloWord {
public static String hello(){
return "hello";
}
public static String word(int a,Integer b){
return "word"+a+"_"+b;
}
}
2.在WEB-INF(子)目录下创建xxx.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 http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd" version="2.0">
<!-- 版本和uri必须写 -->
<tlib-version>1.0</tlib-version>
<uri>/eltag</uri>
<!-- 定义一个函数 -->
<function>
<name>hello</name>
<function-class>cn.syq.tag.HelloWord</function-class>
<function-signature>
java.lang.String hello()
</function-signature>
</function>
<!-- 定义一个函数 -->
<function>
<name>word</name>
<function-class>cn.syq.tag.HelloWord</function-class>
<function-signature>
java.lang.String word(int,java.lang.Integer)
</function-signature>
</function>
</taglib>
3.在jsp文件中引入如下
<%@ taglib uri="/eltag" prefix="eg"%>
<input type="text" value="${eg:hello()}" />
<input type="text" value="${eg:word(2,45)}" />
0 0
- 如何自定义EL函数
- EL自定义函数
- el自定义函数
- JSP自定义EL函数
- EL自定义函数
- 自定义EL函数
- EL表达式-自定义函数
- EL表达式-自定义函数
- 自定义el函数
- EL自定义函数
- 自定义EL函数
- EL自定义函数
- EL自定义函数
- 自定义EL函数
- 自定义EL函数
- EL表达式-自定义函数
- 自定义EL函数
- 自定义el函数
- 宏定义的作用
- linux发展简史
- context:component-scan base-package 通配符写法
- 密码脱落——蓝桥杯
- 阿里的java文档的规范
- 自定义el函数
- android如何进行版本迭代及代码审核
- 多路分支
- C++教程网 大并发高性能高可用可伸缩性服务器开发无KEY
- 《0day安全:软件漏洞分析技术》的一点总结
- No module named cv2
- 在线HTTP接口测试
- 嵌入式linux启动时运行的inittab文件
- 国嵌语言的艺术之C++项目讲解精讲班