<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd"
version="2.4">
改成
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
xmlns:xsi="http://w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd"
version="2.4">
改成
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
xmlns:xsi="http://w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="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>examples</short-name>
<uri>/MyTAG</uri>
<description>A simple tab library for examples</description>
<tag>
<description>Output Hello world.</description>
<name>hello_int</name>
<tag-class>mytag.HelloTag_Interface</tag-class>
<body-content>empty</body-content>
</tag>
</taglib>
我的书上是:
<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-jsptaglibrary_2_0.xsd"
version="2.0">
<description>A tag library exercising SimpleTag handlers.</description>
<tlibversion>1.0</tlibversion>
<shortname>examples</shortname>
<uri>/MyTAG</uri>
<description>A simple tab library for examples</description>
<tag>
<description>Output Hello world.</description>
<name>hello_int</name>
<tagclass>mytag.HelloTag_Interface</tagclass>
<bodycontent>empty</bodycontent>
</tag>
</taglib>
谢谢,已经修改,但出现新的问题,error为:
Error: "TAGjsp.jsp":org.apache.jasper.JasperException: XML parsing error on file /WEB-INF/web.xml:(line 3,col -1):组件类型"taglib"未被声明。
to nimifeng(蜜蜂不小了.):
不好意思,我看不出两段程序有什么区别
将这一行加到你的mytag.tld文件中的第二行,也就是<?xml...>的后面
Warn:Invalid PUBLIC ID :-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN
Error:"TAGjsp.jsp":org.apache.jasper.JasperException: XML parsing error on file /WEB-INF/tlds/mytag.tld:(line 3,col -1):未找到外部实体"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd"
如果这样干脆将<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-jsptaglibrary_2_0.xsd"
version="2.0">
换成<taglib>
然后在第二行加上刚才的一句!
随便找一个配置正确的tld文件,按着它配置就行了!
我也想找一个配置正确的tld文件啊,问题是这些书上说的"正常的"tld文件,在我这里都报错