注册 登录
编程论坛 J2EE论坛

[求助]EL自定义函数的问题。。。错在哪儿呢?

xinqing12312 发布于 2007-03-23 17:33, 777 次点击
运行后提示:
org.apache.jasper.JasperException: The class specified in the method signature in TLD for the function Greeting:greet cannot be found.

文件greeting.jsp:
<%@ page contentType="text/html; charset=GBK"%>
<%@ taglib prefix="Greeting"uri="/myGreeting"%>
<html>
<body>
${Greeting:greet()}
</body>
</html>

文件web.xml
<taglib>
<taglib-uri>
/myGreeting
</taglib-uri>
<taglib-location>
/WEB-INF/taglib.tld
</taglib-location>
</taglib>

文件taglib.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 http://java.sun.com/xml/ns/j2ee"
version="2.0">
<tlib-version>1.1</tlib-version>
<jsp-version>2.0</jsp-version>
<short-name>Greeting</short-name>
<uri>/myGreeting</uri>
<function>
<name>greet</name>
<function-class>myFunction.Functions</function-class>
<function-signature>java.lang.String sayHello()</function-signature>
</function>
</taglib>

WEB-INF/classes/myFunction中有Functions.class
3 回复
#2
时空之蕊2007-03-23 17:39
<?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 http://java.sun.com/xml/ns/j2ee"
version="2.0">
<tlib-version>1.1</tlib-version>
<short-name>Greeting</short-name>
<uri>myGreeting</uri>
<function>
<name>greet</name>
<function-class>myFunction.Functions</function-class>
<function-signature>java.lang.String sayHello()</function-signature>
</function>
</taglib>
#3
xinqing123122007-03-26 08:55

不行啊 修改后还是同样的错误

#4
nodonkey2007-04-13 16:19
回复:(xinqing12312)[求助]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 http://java.sun.com/xml/ns/j2ee"
version="2.0">
<tlib-version>1.1</tlib-version>
<jsp-version>2.0</jsp-version>
<short-name>Greeting</short-name>
<uri>/myGreeting</uri>
<function>
<name>greet</name>
<function-class>myFunction.Functions</function-class>
<function-signature>java.lang.String sayHello()</function-signature>
</function>
</taglib>
中的
<short-name>Greeting</short-name>
换成其他的名称看

1