这里是java文件,函数里面有一个参数是我自己定义的类
package EL;
import java.util.List;
import model.Course;
public class IsContain {
public IsContain() {
// TODO Auto-generated constructor stub
}
/*
* 判断已选的课程中是否包含某一特定课程*/
public static boolean IsContain(List<Course> list,Course course){
if(list.contains(course))
return true;
else
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">
<description>my</description>
<display-name>my</display-name>
<tlib-version>1.0</tlib-version>
<!--定义引用,要和web.xml中的<taglib-uri>一致-->
<uri>/my</uri>
<!-- 定义总的名称,引用时的prefix -->
<short-name>my</short-name>
<function>
<!-- 定义方法名称 -->
<name>IsContain</name>
<!-- 定义方法所在类的地址-->
<function-class>EL.IsContain</function-class>
<!-- 定义方法名称 标签-->
<function-signature>
java.lang.Boolean IsContain(java.util.List,java.lang.Object)
</function-signature>
</function>
</taglib>
--------------------------------------------------------------------------------------------------------------
jsp页面引用:<%@ taglib uri="/my" prefix="my"%>
<c:forEach items="${courseList}" var="course" varStatus="vv">
${my:IsContain(selectedCourses,course)}
</c:forEach>
请问大家这个对象的参数在TLD文件中这样写对吗?测试的时候不通过。
----------------------------------------------------------------------------------------------------------------------
错误如下:
type Exception report
message Method "IsContain" for function "IsContain" not found in class "EL.IsContain"
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Method "IsContain" for function "IsContain" not found in class "EL.IsContain"
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:56)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:410)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:182)
org.apache.jasper.compiler.Validator$ValidateVisitor$1MapperELVisitor.visit(Validator.java:1694)
org.apache.jasper.compiler.ELNode$Function.accept(ELNode.java:137)
------解决方案--------------------
你看你的Course在哪个包下面呀?包名.类名应该可以,如果还不行的话,可能就不支持自定义类型吧