是不是你缺少某个tld?
找个完整的可以运行的,试试看。

解决方案 »

  1.   

    我把原文件添上,希望大家帮忙解决!!!
    ExampeTag.java 目录是install_dir/ROOT/WEB-INF/classes/moreservlets/tags/ExampleTag.class.=================================================
    package moreservlets.tags;import javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    import java.io.*;/** Very simple JSP tag that just inserts a string
     *  ("Custom tag example...") into the output.
     *  The actual name of the tag is not defined here;
     *  that is given by the Tag Library Descriptor (TLD)
     *  file that is referenced by the taglib directive
     *  in the JSP file.
     *  <P>
     *  Taken from More Servlets and JavaServer Pages
     *  from Prentice Hall and Sun Microsystems Press,
     *  http://www.moreservlets.com/.
     *  &copy; 2002 Marty Hall; may be freely used or adapted.
     */public class ExampleTag extends TagSupport {
      public int doStartTag() {
        try {
          JspWriter out = pageContext.getOut();
          out.print("Custom tag example " +
                    "(moreservlets.tags.ExampleTag)");
        } catch(IOException ioe) {
          System.out.println("Error in ExampleTag: " + ioe);
        }
        return(SKIP_BODY);
      }
    }
    ============================================================
    installdir\webapps\ROOT\WEB-INF\tlds\msajsp-taglib.tld<?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE taglib
     PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
     "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd"><!-- a tag library descriptor --><taglib>
      <tlibversion>1.0</tlibversion>
      <jspversion>1.1</jspversion>
      <shortname>msajsp-tags</shortname>
      <info>
        A tag library from More Servlets and JavaServer Pages,
        http://www.moreservlets.com/.
      </info><!--
      <tag>
        The name (after prefix) tag will have in JSP code
        <name>example</name>    The actual class implementing tag. In
        Tomcat, it MUST be in a package.
        <tagclass>moreservlets.tags.ExampleTag</tagclass>    One of three values describing what goes between
        start and end tag. 
          empty: no body 
          JSP: body that is evaluated by container normally,
               then possibly processed by tag
          tagdependent: body is only processed by tag;
                        JSP in body is not evaluated. 
        <bodycontent>empty</bodycontent>    Descriptive information about tag.
        <info>Simplest example: inserts one line of output</info>
      </tag>      
    -->  <tag>
        <name>example</name>
        <tagclass>moreservlets.tags.ExampleTag</tagclass>
        <bodycontent>empty</bodycontent>
        <info>Simplest example: inserts one line of output</info>
      </tag>        <tag>
        <name>simplePrime</name>
        <tagclass>moreservlets.tags.SimplePrimeTag</tagclass>
        <bodycontent>empty</bodycontent>
        <info>Outputs a random 50-digit prime.</info>
      </tag>  <tag>
        <name>prime</name>
        <tagclass>moreservlets.tags.PrimeTag</tagclass>
        <bodycontent>empty</bodycontent>
        <info>Outputs a random N-digit prime.</info>
        <attribute>
          <name>length</name>
          <required>false</required>
        </attribute>
      </tag>  <tag>
        <name>heading</name>
        <tagclass>moreservlets.tags.HeadingTag</tagclass>
        <bodycontent>JSP</bodycontent>
        <info>Outputs a 1-cell table used as a heading.</info>
        <attribute>
          <name>bgColor</name>
          <required>true</required>  <!-- bgColor is required -->
        </attribute>
        <attribute>
          <name>color</name>
          <required>false</required>
        </attribute>
        <attribute>
          <name>align</name>
          <required>false</required>
        </attribute>
        <attribute>
          <name>fontSize</name>
          <required>false</required>
        </attribute>
        <attribute>
          <name>fontList</name>
          <required>false</required>
        </attribute>
        <attribute>
          <name>border</name>
          <required>false</required>
        </attribute>
        <attribute>
          <name>width</name>
          <required>false</required>
        </attribute>
      </tag>  <tag>
        <name>debug</name>
        <tagclass>moreservlets.tags.DebugTag</tagclass>
        <bodycontent>JSP</bodycontent>
        <info>Includes body only if debug param is set.</info>
      </tag>  <tag>
        <name>filter</name>
        <tagclass>moreservlets.tags.FilterTag</tagclass>
        <bodycontent>JSP</bodycontent>
        <info>Replaces HTML-specific characters in body.</info>
      </tag>  <tag>
        <name>repeat</name>
        <tagclass>moreservlets.tags.RepeatTag</tagclass>
        <bodycontent>JSP</bodycontent>
        <info>Repeats body the specified number of times.</info>
        <attribute>
          <name>reps</name>
          <required>true</required>
          <!-- rtexprvalue indicates whether attribute
               can be a JSP expression. -->
          <rtexprvalue>true</rtexprvalue>
        </attribute>
      </tag>  <tag>
        <name>if</name>
        <tagclass>moreservlets.tags.IfTag</tagclass>
        <bodycontent>JSP</bodycontent>
        <info>if/condition/then/else tag.</info>
      </tag>
      <tag>
        <name>condition</name>
        <tagclass>moreservlets.tags.IfConditionTag</tagclass>
        <bodycontent>JSP</bodycontent>
        <info>condition part of if/condition/then/else tag.</info>
      </tag>
      <tag>
        <name>then</name>
        <tagclass>moreservlets.tags.IfThenTag</tagclass>
        <bodycontent>JSP</bodycontent>
        <info>then part of if/condition/then/else tag.</info>
      </tag>
      <tag>
        <name>else</name>
        <tagclass>moreservlets.tags.IfElseTag</tagclass>
        <bodycontent>JSP</bodycontent>
        <info>else part of if/condition/then/else tag.</info>
      </tag></taglib>
    ====================================================
    installdir\webapps\ROOT\jsp-intro\SimpleExample.jsp<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <!-- 
    Illustration of very simple JSP custom tag. Taken from More Servlets and JavaServer Pages
    from Prentice Hall and Sun Microsystems Press,
    http://www.moreservlets.com/.
    (C) 2002 Marty Hall; may be freely used or adapted.
    -->
    <HTML>
    <HEAD>
    <%@ taglib uri="/msajsp-taglib.tld" prefix="msajsp" %>
    <TITLE><msajsp:example /></TITLE>
    <LINK REL=STYLESHEET
          HREF="JSP-Styles.css"
          TYPE="text/css">
    </HEAD>
    <BODY>
    <H1><msajsp:example /></H1>
    <msajsp:example />
    </BODY>
    </HTML>=================================================
    运行http://localhost/jsp-intro/SimpleExample.jsp,
    org.apache.jasper.JasperException: Unable to initialize TldLocationsCache: zip file closed
      

  2.   

    我的tomcat不能运行struts的标签:(
      

  3.   

    to dytsoft(anway.vicp.net)能给个例子么或打个比方??
      

  4.   

    %JAVA_HOME%\lib;%TOMCAT_HOME%\common\lib加入环境变量,也不行,还是一样
      

  5.   

    <%@ taglib uri="/msajsp-taglib.tld" prefix="msajsp" %>文件msajsp-taglib.tld位置没有放对。以jstl为例子:目录结构如下tag file:\tagtest\WEB-INF\c.tld
    web.xml: \tagtest\WEB-INF\web.xml
    testjsp: \tagtest\test.jsp
    其中web.xml内容为:    <taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
        <taglib-location>/WEB-INF/c.tld</taglib-location>
        </taglib>test.jsp内容为:
    <%@ page contentType = "text/html; charset=GBK"%>
    <%@ taglib uri = "http://java.sun.com/jstl/core" prefix = "c"%>
    对照着看一下吧,应该就明白了。
      

  6.   

    JSP文件修改如下 <%@ taglib uri="Tag" prefix="msajsp" %>
    web.xml修改如下
    <taglib>
        <taglib-uri>Tag</taglib-uri>
        <taglib-location>/WEB-INF/tlds/msajsp-taglib.tld</taglib-location>
      </taglib>但是还是不行呀!!!msajsp-taglib.tld目录是C:\Tomcat 5.0\webapps\ROOT\WEB-INF\tlds
      

  7.   

    <%@ taglib uri="Tag" prefix="msajsp" %>
    中的uri 和<taglib-uri></taglib-uri>中的一致了呀??怎么还是不行呢?希望大家帮帮忙,楼上的大哥非常感谢,但是我还是没试出来,请帮忙想想吧,我已经没折了!!!
      

  8.   

    a.jsp<HTML>
    <HEAD>
    <%@ taglib uri="Tag" prefix="msajsp" %>
    <TITLE><msajsp:example /></TITLE>
    <LINK REL=STYLESHEET
          HREF="JSP-Styles.css"
          TYPE="text/css">
    </HEAD>
    <BODY>
    <H1><msajsp:example /></H1>
    <msajsp:example />
    </BODY>
    </HTML>web.xml
    <?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE web-app
        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
        "http://java.sun.com/dtd/web-app_2_3.dtd"><web-app>
      <display-name>Welcome to Tomcat</display-name>
      <description>
         Welcome to Tomcat
      </description>
    <!-- JSPC servlet mappings start -->    <servlet>
            <servlet-name>org.apache.jsp.index_jsp</servlet-name>
            <servlet-class>org.apache.jsp.index_jsp</servlet-class>
        </servlet>    <servlet-mapping>
            <servlet-name>org.apache.jsp.index_jsp</servlet-name>
            <url-pattern>/index.jsp</url-pattern>
        </servlet-mapping>
        <servlet>
            <servlet-name>moreservlets.HelloServlet2</servlet-name>
            <servlet-class>moreservlets.HelloServlet2</servlet-class>
        </servlet>    <servlet-mapping>
            <servlet-name>moreservlets.HelloServlet2</servlet-name>
            <url-pattern>/moreservlets.HelloServlet2</url-pattern>
        </servlet-mapping><servlet>
            <servlet-name>moreservlets.ThreeParams</servlet-name>
            <servlet-class>moreservlets.ThreeParams</servlet-class>
        </servlet>    <servlet-mapping>
            <servlet-name>moreservlets.ThreeParams</servlet-name>
            <url-pattern>/servlet/moreservlets.ThreeParams</url-pattern>
        </servlet-mapping>
        
        <servlet>
            <servlet-name>ShowRequestHeaders</servlet-name>
            <servlet-class>moreservlets.ShowRequestHeaders</servlet-class>
        </servlet>    <servlet-mapping>
            <servlet-name>ShowRequestHeaders</servlet-name>
            <url-pattern>/servlet/moreservlets.ShowRequestHeaders</url-pattern>
        </servlet-mapping><servlet>
            <servlet-name>moreservlets.HelloServlet3</servlet-name>
            <servlet-class>moreservlets.HelloServlet3</servlet-class>
        </servlet>    <servlet-mapping>
            <servlet-name>moreservlets.HelloServlet3</servlet-name>
            <url-pattern>/moreservlets.HelloServlet3</url-pattern>
        </servlet-mapping>
        
        <servlet>
            <servlet-name>SearchEngines</servlet-name>
            <servlet-class>moreservlets.SearchEngines</servlet-class>
        </servlet>    <servlet-mapping>
            <servlet-name>SearchEngines</servlet-name>
            <url-pattern>/servlet/moreservlets.SearchEngines</url-pattern>
        </servlet-mapping>
    <!-- JSPC servlet mappings end -->
    <!-- If URL gives a directory but no filename, try index.jsp
           first and index.html second. If neither is found,
           the result is server specific (e.g., a directory 
           listing).  
      -->
      <!-- Register names for the ShowItem and ShowPurchases
           servlets. These names will be used with servlet-mapping
           to set custom URLs.
      -->
      <servlet>
        <servlet-name>ShowItem</servlet-name>
        <servlet-class>moreservlets.ShowItem</servlet-class>
      </servlet>
      <servlet>
        <servlet-name>ShowPurchases</servlet-name>
        <servlet-class>moreservlets.ShowPurchases</servlet-class>
      </servlet>  <!-- Set the URL http://host/webAppName/DisplayPurchases
           to invoke the servlet that would otherwise be
           available with the URL 
           http://host/webAppName/servlet/moreservlets.ShowPurchases
      -->
      <servlet-mapping>
        <servlet-name>ShowPurchases</servlet-name>
        <url-pattern>/DisplayPurchases</url-pattern>
      </servlet-mapping>  <!-- Set the URL http://host/webAppName/DisplayItem
           to invoke the servlet that would otherwise be
           available with the URL 
           http://host/webAppName/servlet/moreservlets.ShowItem
      -->
      <servlet-mapping>
        <servlet-name>ShowItem</servlet-name>
        <url-pattern>/DisplayItem</url-pattern>
      </servlet-mapping>
      <welcome-file-list>
        <welcome-file>index1.jsp</welcome-file>
        <welcome-file>index.html</welcome-file>
      </welcome-file-list>
     
     <taglib>
        <taglib-uri>Tag</taglib-uri>
        <taglib-location>/WEB-INF/tlds/msajsp-taglib.tld</taglib-location>
      </taglib></web-app>
    =================================================
    这是修改后的文件。