jsp 自定义函数 调用时包 在类中找不到这个方法 20
类:publicstaticStringgetSubStr(Stringstr,intstart,intsize){str=str.replaceAll("","");r...
类:
public static String getSubStr(String str,int start,int size){
str=str.replaceAll(" ","");
return str.length()>(start+size)?str.substring(start, start+size):str.substring(start);
}
tld文件:
<function>
<name>getSubStr</name>
<function-class>com.applet.hgzsjsj.util.utils</function-class>
<function-signature>java.lang.String getSubStr(java.lang.String,java.lang.Integer,java.lang.Integer)</function-signature>
</function>
页面调用:
<%@ taglib uri="WEB-INF/UTILS.tld" prefix="ucFn" %>
${ucFn:getSubStr("This is my JSP page.",0,8) }
出现的异常:
org.apache.jasper.JasperException: Method "getSubStr" for function "getSubStr" not found in class "com.applet.hgzsjsj.util.utils"
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:181)
at org.apache.jasper.compiler.Validator$ValidateVisitor$1MapperELVisitor.visit(Validator.java:1637)
at org.apache.jasper.compiler.ELNode$Function.accept(ELNode.java:129)
at org.apache.jasper.compiler.ELNode$Nodes.visit(ELNode.java:200)
at org.apache.jasper.compiler.ELNode$Visitor.visit(ELNode.java:242)
at org.apache.jasper.compiler.ELNode$Root.accept(ELNode.java:56)
at org.apache.jasper.compiler.ELNode$Nodes.visit(ELNode.java:200)
at org.apache.jasper.compiler.Validator$ValidateVisitor.getFunctionMapper(Validator.java:1646)
找到原因了,函数不能 进行int类型的传值。 展开
public static String getSubStr(String str,int start,int size){
str=str.replaceAll(" ","");
return str.length()>(start+size)?str.substring(start, start+size):str.substring(start);
}
tld文件:
<function>
<name>getSubStr</name>
<function-class>com.applet.hgzsjsj.util.utils</function-class>
<function-signature>java.lang.String getSubStr(java.lang.String,java.lang.Integer,java.lang.Integer)</function-signature>
</function>
页面调用:
<%@ taglib uri="WEB-INF/UTILS.tld" prefix="ucFn" %>
${ucFn:getSubStr("This is my JSP page.",0,8) }
出现的异常:
org.apache.jasper.JasperException: Method "getSubStr" for function "getSubStr" not found in class "com.applet.hgzsjsj.util.utils"
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:181)
at org.apache.jasper.compiler.Validator$ValidateVisitor$1MapperELVisitor.visit(Validator.java:1637)
at org.apache.jasper.compiler.ELNode$Function.accept(ELNode.java:129)
at org.apache.jasper.compiler.ELNode$Nodes.visit(ELNode.java:200)
at org.apache.jasper.compiler.ELNode$Visitor.visit(ELNode.java:242)
at org.apache.jasper.compiler.ELNode$Root.accept(ELNode.java:56)
at org.apache.jasper.compiler.ELNode$Nodes.visit(ELNode.java:200)
at org.apache.jasper.compiler.Validator$ValidateVisitor.getFunctionMapper(Validator.java:1646)
找到原因了,函数不能 进行int类型的传值。 展开
2个回答
展开全部
<function-class>com.applet.hgzsjsj.util.utils</function-class>
改为
<function-class>com.applet.hgzsjsj.util.utils.class</function-class>
不行的话检查一下你的包名和类名是否正确
改为
<function-class>com.applet.hgzsjsj.util.utils.class</function-class>
不行的话检查一下你的包名和类名是否正确
追问
不行,包名及类名都是正确的
追答
我做的tld和你用的方法不太一样给你参考下看看
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |