<?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>JSTL 1.1 core library</description>
  <display-name>JSTL core</display-name>
  <tlib-version>1.1</tlib-version>
  <short-name>c</short-name>
  <uri>http://java.sun.com/jsp/jstl/core</uri>  <validator>
    <description>
        Provides core validation features for JSTL tags.
    </description>
    <validator-class>
        org.apache.taglibs.standard.tlv.JstlCoreTLV
    </validator-class>
  </validator>  <tag>
    <description>
        Catches any Throwable that occurs in its body and optionally
        exposes it.
    </description>
    <name>catch</name>
    <tag-class>org.apache.taglibs.standard.tag.common.core.CatchTag</tag-class>
    <body-content>JSP</body-content>
    <attribute>
        <description>
Name of the exported scoped variable for the
exception thrown from a nested action. The type of the
scoped variable is the type of the exception thrown.
        </description>
        <name>var</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
  </tag>
</taglib>

解决方案 »

  1.   

    我看到楼上些的代码里没有<function></function>标签
    只是一个标准的标签文件,我想在jsp页面里使用标签函数。
      

  2.   

    要在lib中导入一个jar包,然后就可以使用
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <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">
      <tlib-version>1.0</tlib-version>
      <jsp-version>1.2</jsp-version>
      <short-name>function</short-name>
      <uri>http://hellking.com/function</uri>
      <display-name>JSTL sql RT</display-name>
      <description>my function</description>  
      <function>
      <name>add</name>
      <function-class>com.jspdev.ch16.Function</function-class>
      <function-signature>int add(int,int)</function-signature>
      </function> 
      <function>
      <name>trans</name>
      <function-class>com.jspdev.ch16.Function</function-class>
      <function-signature>java.lang.String trans(java.lang.String)</function-signature>
      </function> 
    <function>
      <name>formatPer</name>
      <function-class>com.jspdev.ch16.PerUtil</function-class>
      <function-signature>java.lang.String formatPer(float)</function-signature>
      </function> 
    </taglib>
    JSP应用开发详解(第二版)上有
      

  3.   

    to:IBug008()
    在lib中导入那个jar包呢?
    我的项目下已经导入了JSTL标签库
      

  4.   

    导入jstl,standard包(Jbuilder上有):
    1。建立类Function package eldemo;import java.io.*;public class Function {
         //中文转换
        public static String tarns(String chi)
        {
           String result=null;
           byte temp[];        try {
                temp = chi.getBytes("iso-8859-1");
                result = new String(temp);
            } catch (UnsupportedEncodingException ex) {
                ex.printStackTrace();
            }
            return result;
        }
           //测试用
        public static int add(int x,int y)
        {
           return x+y;
        }
    }
    2。 建立func.tld,源码如下:
    <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">    <tlib-version>1.0</tlib-version>
        <short-name>function</short-name>
        <uri>http://wq.com/function</uri>
        <display-name>JSTL sql RT</display-name>
        <description>my function</description>    <function>
            <name>add</name>
            <function-class>eldemo.Function</function-class>
            <function-signature>int add(int,int)</function-signature>
        </function>    <function>
             <name>trans</name>
             <function-class>eldemo.Function</function-class>
             <function-signature>java.lang.String trans(java.lang.String)</function-signature>
        </function>
    </taglib>3。然后再web.xml上配置
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app 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-app_2_4.xsd" version="2.4">
      <display-name>Demo</display-name>
      <jsp-config>
        <taglib>
          <taglib-uri>http://wq.com/function</taglib-uri>
          <taglib-location>/WEB-INF/func.tld</taglib-location>
        </taglib>
      </jsp-config>
    </web-app>4。可以直接调用(fun.jsp)
    <%@ page contentType="text/html; charset=GBK" %>
    <%@ taglib prefix="my" uri="http://wq.com/function" %>
    <html>
    <head>
    <title>
    MyFun
    </title>
    </head>
    <body bgcolor="#ffffff">
    <h1>
    ${my:add(10,20)}
    </h1>
    </body>
    </html>