dvppoalsdgss 2018-10-09 05:32 采纳率: 0%
浏览 631
已采纳

自定义EL函数提示没找到方法报错

 package cn.itcast.web.el;

public class ElUtils {

    public static String subString(String source,int length){

        if(source.length()>length){
            return source.substring(0, length) + "......";
        }

        return source;
    }

}

 <?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">
    <description>A tag library exercising SimpleTag handlers.</description>
    <tlib-version>1.0</tlib-version>
    <short-name>SimpleTagLibrary</short-name>
    <uri>/WEB-INF/itcast</uri>

   <function>        
        <name>subString</name>
        <function-class>cn.itcast.web.el.ElUtils</function-class>
        <function-signature>java.lang.String subString(java.lang.String,java.lang.Integer)</function-signature>
    </function>
</taglib>
 <%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="/WEB-INF/itcast" prefix="itcast"%>
 严重: Servlet [listcustomer] in web application [/day15_customer] threw load() exception
org.apache.jasper.JasperException: Method "subString" for function "subString" not found in class "cn.itcast.web.el.ElUtils"
    at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:55)
    at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:277)
    at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:75)
    at org.apache.jasper.compiler.Validator$ValidateVisitor$1MapperELVisitor.visit(Validator.java:1751)
    at org.apache.jasper.compiler.ELNode$Function.accept(ELNode.java:139)
    at org.apache.jasper.compiler.ELNode$Nodes.visit(ELNode.java:214)
    at org.apache.jasper.compiler.ELNode$Visitor.visit(ELNode.java:256)
    at org.apache.jasper.compiler.ELNode$Root.accept(ELNode.java:61)
    at org.apache.jasper.compiler.ELNode$Nodes.visit(ELNode.java:214)
    at org.apache.jasper.compiler.Validator$ValidateVisitor.getFunctionMapper(Validator.java:1760)
    at org.apache.jasper.compiler.Validator$ValidateVisitor.getJspAttribute(Validator.java:1416)
    at org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:1231)
    at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:879)
    at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1536)
    at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
    at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
    at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:898)
    at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1536)
    at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
    at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
    at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:898)
    at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1536)
    at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
    at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
    at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:898)
    at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1536)
    at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
    at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
    at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434)
    at org.apache.jasper.compiler.Node$Root.accept(Node.java:464)
    at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
    at org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1853)
    at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:219)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:358)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:338)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:325)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:580)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:363)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
    at org.apache.jasper.servlet.JspServlet.init(JspServlet.java:138)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1227)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1140)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1027)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5037)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5347)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
  • 写回答

2条回答 默认 最新

  • Mr_Huang_ning 2018-10-10 01:47
    关注

    cn.itcast.web.el.ElUtils
    java.lang.String subString(java.lang.String,java.lang.Integer)
    这个地方写错了,第二行你写的是String类的subString 方法,应该是写你自己定义的那个类下面的subString方法

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 微信夜间被转走了1w对,当天手机剪切板里就出现了这个乱码,有铁子可以看看是啥吗可以
  • ¥50 跑通github上的代码 深度学习 pytorch
  • ¥50 求写,批处理调用分区助手分区脚本
  • ¥15 求购HI3519AV100开发板
  • ¥15 请问1553 RT怎么测试,没有BC有方法吗
  • ¥100 业务编程如何选择学习方向和内容?
  • ¥15 wamp3.3.5安装完成后图标正常显示绿色,鼠标左右键点击图标均无反应。求解决方法。
  • ¥15 鼠标点击的这条记录了什么?
  • ¥15 在写pid调速的程序时,电机始终维持最大速度
  • ¥15 【有偿】调用DXGI截图初始化失败,提示0xf 887a0004