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条)

报告相同问题?

悬赏问题

  • ¥50 gki vendor hook
  • ¥15 centos7中sudo命令无法使用
  • ¥15 灰狼算法和蚁群算法如何结合
  • ¥15 这是一个利用ESP32自带按键和LED控制的录像代码,编译过程出现问题,请解决并且指出错误,指导如何处理 ,协助完成代码并上传代码
  • ¥20 stm32f103,hal库 hal_usart_receive函数接收不到数据。
  • ¥20 求结果和代码,sas利用OPTEX程序和D-efficiency生成正交集
  • ¥50 adb连接不到手机是怎么回事?
  • ¥20 抓取数据时发生错误: get_mooncake_data() missing 1 required positional argument: 'driver'的问题,怎么改出正确的爬虫代码?
  • ¥15 vs2022无法联网
  • ¥15 TCP的客户端和服务器的互联