有关自定义EL函数问题。急急急!
我自己定义了一个EL函数,但是不知道问什么总是报错。下边一一列出:
1、web。xml,增加如下内容:
<jsp-config>
<taglib>
<taglib-uri>http://founder/gy/ers/myFunctions</taglib-uri>
<taglib-location>/WEB-INF/myFunctions.tld</taglib-location>
</taglib>
</jsp-config>
2、myFunctions.tlb内容:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE taglib
PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
"http://java.sun.com/j2ee/dtd/web-jsptaglibrary_1_2.dtd">
<taglib>
<tlib-version>1.0</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>myFunctions</short-name>
<uri>/myFunctions</uri>
<function>
<description></description>
<name>subString</name>
<function-class>com.founder.gy.ers.beans.ELFunction</function-class>
<function-signature>java.lang.String subString( java.lang.String, int, int )
</function-signature>
</function>
</taglib>
3、ELFunction类的内容:
package com.founder.gy.ers.beans;
public class ELFunction {
public ELFunction(){
}
public static String subString(String str,int startIndex,int endIndex)
{
return str.substring(startIndex,endIndex);
}
public static String subString(String str,int startIndex)
{
return str.substring(startIndex);
}
}
4、在页面中使用:
<%@ taglib uri="http://founder/gy/ers/myFunctions" prefix="myFn" %>
<c:set value="abcdef" var="test">
</c:set>
${myFn:subString(test,1,2)}
最后报错信息如下:
org.apache.jasper.JasperException: The class com.founder.gy.ers.beans.ELFunction specified in TLD for the function myFn:subString cannot be found: com.founder.gy.ers.beans.ELFunction