//这是将要调用的静态方法
public static String TestMethod(String str)
{
return str+"aaaaaaaaaaaaaa";

}
//这是ELFunction.tld中对EL函数的说明
<function>
<name>TestMethod</name>
<function-class>com.Huaye.ELFunction.ELFunction</function-class>
<function-signature>String TestMethod(String)</function-signature>
</function>//这是Web.xml中对EL的配置<jsp-config> <taglib>
<taglib-uri>/intercept</taglib-uri>
<taglib-location>/WEB-INF/tlds/ELFunction.tld</taglib-location>
</taglib> </jsp-config>
//最后是JSP中的代码了<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
<%@ taglib prefix="inter" uri="/intercept" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>My JSP 'MyJsp.jsp' starting page</title>
  </head>
  
  <body>
  
   ${inter:TestMethod("a") } 
  
  </body>
</html>

解决方案 »

  1.   

    忘了写报错消息了,这是报错消息
    HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: The class String specified in the method signature in TLD for the function inter:TestMethod cannot be found. String
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:564)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:353)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:319)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause org.apache.jasper.JasperException: The class String specified in the method signature in TLD for the function inter:TestMethod cannot be found. String
    org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:50)
    org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
    org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:179)
    org.apache.jasper.compiler.Validator$ValidateVisitor$1MapperELVisitor.visit(Validator.java:1440)
    org.apache.jasper.compiler.ELNode$Function.accept(ELNode.java:122)
    org.apache.jasper.compiler.ELNode$Nodes.visit(ELNode.java:193)
    org.apache.jasper.compiler.ELNode$Visitor.visit(ELNode.java:234)
    org.apache.jasper.compiler.ELNode$Root.accept(ELNode.java:53)
    org.apache.jasper.compiler.ELNode$Nodes.visit(ELNode.java:193)
    org.apache.jasper.compiler.Validator$ValidateVisitor.getFunctionMapper(Validator.java:1453)
    org.apache.jasper.compiler.Validator$ValidateVisitor.prepareExpression(Validator.java:1321)
    org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:678)
    org.apache.jasper.compiler.Node$ELExpression.accept(Node.java:920)
    org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2321)
    org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2371)
    org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2377)
    org.apache.jasper.compiler.Node$Root.accept(Node.java:482)
    org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2321)
    org.apache.jasper.compiler.Validator.validate(Validator.java:1549)
    org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:177)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:305)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:285)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:272)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:565)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:313)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:319)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    note The full stack trace of the root cause is available in the Apache Tomcat/6.0.0 logs.
    --------------------------------------------------------------------------------Apache Tomcat/6.0.0
      

  2.   

    用了JSP哪个版本?TLD文件是这样配置吗?
      

  3.   

    org.apache.jasper.JasperException: The class String specified in the method signature in TLD for the function inter:TestMethod cannot be found. String 这个错误是说在tld中找不到 inter:TestMethod函数,在jsp有${inter:TestMethod("a") }使用的吗?
      

  4.   

    <%@ taglib prefix="inter" uri="/intercept" %>
    这个是不是有问题啊,绝对路径试试呢
      

  5.   

    确定这个是正确的类路径?<function-class>com.Huaye.ELFunction.ELFunction</function-class>
      

  6.   

    配置文件有错,检查一下!!EL表达式作用域的范围有四种 pageContext,request,session,application。
    建议用struts标签库 <s:propert value=""/>
      

  7.   

    解决了呵呵!是参数问题在函数说明中String要改成java.lang.String 才行