tld文件的配置

qinwen0101 2007-07-31 06:40:50
我配置tld文件时提示〈taglib〉不能找到这个标签,但是我已经写上了,同是在web.xml是这样配置的:〈jsp-config〉<taglib>

</taglib></jsp-config>
并且能够通过,说明这已经没有问题了,另外这两个文件有什么样的联系?谢谢!
...全文
1223 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
m540920181 2011-11-27
  • 打赏
  • 举报
回复
[Quote=引用楼主 qinwen0101 的回复:]
我配置tld文件时提示〈taglib〉不能找到这个标签,但是我已经写上了,同是在web.xml是这样配置的:〈jsp-config〉 <taglib>

</taglib> </jsp-config>
并且能够通过,说明这已经没有问题了,另外这两个文件有什么样的联系?谢谢!
[/Quote]

有没有导入4个jar包啊,使用taglib标签,需要导包的
kaka800822 2011-11-27
  • 打赏
  • 举报
回复
你好,这个问题我已经有解决,需要在tld文件头上加上如下:
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd" >
yztommyhc 2007-08-02
  • 打赏
  • 举报
回复
<%@ taglib uri="/demotag" prefix="ww"%>
prefix="ww"指定你用这个标签的前缀.
property 是你的.Tld文件给你的类起的名字
如----  ww:property

jsp页面是这样写的么?常犯的错误是丢掉了"/demotag"中的"/"
zhuxr2003 2007-08-01
  • 打赏
  • 举报
回复
<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>A tag library exercising SimpleTag handlers.</description>
<tlib-version>1.0</tlib-version>

改成<taglib>试试
zhuxr2003 2007-08-01
  • 打赏
  • 举报
回复
jsp是怎么写的?
qinwen0101 2007-08-01
  • 打赏
  • 举报
回复
不会的,以下分别是我的tld文件和web.xml文件:
web.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
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">

<display-name>Welcome to Tomcat</display-name>
<description>
Welcome to Tomcat
</description>
<jsp-config>
<taglib>
<taglib-uri>/demotag</taglib-uri>
<taglib-location>/WEB-INF/tlds/mytag.tld</taglib-location>
</taglib>
</jsp-config>

</web-app>

mytag.tld文件:
<?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">
<description>A tag library exercising SimpleTag handlers.</description>
<tlib-version>1.0</tlib-version>

<short-name>examples</short-name>
<uri>/demotag</uri>
<description>
A simple tab library for the examples
</description>

<tag>
<name>hello</name>
<tag-class>com.jspdev.ch14.HelloTag</tag-class>
<body-content>empty</body-content>
<description>
Simple hello world examples.
Takes no attribute,and simply generates HTML
</description>
</tag>
</taglib>

现在<taglib>标签旁有一个红色的小错号,提示:
cannot find the declaration of element 'taglib'
月海 2007-08-01
  • 打赏
  • 举报
回复
你在web.xml 中可以不用重新写你的路径。
在你的jsp引用的位置写 .tld得确切位置就可以减少错误的发生了

<%@ taglib uri="/WEB-INF/tlds/mytag.tld" prefix="ww"%>
prefix="ww"指定你用这个标签的前缀.
property 是你的.Tld文件给你的类起的名字
如----  ww:property
yqh2009 2007-07-31
  • 打赏
  • 举报
回复
会不会是你得tld文件忘了写 <taglib>
qinwen0101 2007-07-31
  • 打赏
  • 举报
回复
谢谢楼上这么详细的讲解.
现在那个tld文件中提示不能找到 "<taglib>"标签,这个该怎样解决呢?
yztommyhc 2007-07-31
  • 打赏
  • 举报
回复
<%@ taglib uri="/ww" prefix="ww"%>
prefix="ww"指定你用这个标签的前缀.
如----  ww:property
yztommyhc 2007-07-31
  • 打赏
  • 举报
回复
web.xml与tld文件的关系:
由web.xml指示tld文件的实际位置和引用名称.
<jsp-config>
<taglib>
<taglib-uri>以什么样的名称引用</taglib-uri>
<taglib-location>在工程中的位置</taglib-location>
</taglib>
</jsp-config>

在jsp界面中一般用引用名称.
你可以对你下你的tld路径是否正确,jsp中的引用和web.xml中<taglib-uri>以什么样的名称引用</taglib-uri>是否一致.

如jsp文件中
<%@ taglib uri="/ww" prefix="ww"%>
web.xml
<jsp-config>
<taglib>
<taglib-uri>/ww</taglib-uri>
<taglib-location>在工程中的位置</taglib-location>
</taglib>
</jsp-config>

qinwen0101 2007-07-31
  • 打赏
  • 举报
回复
web.xml与tld文件的关系?
great_king 2007-07-31
  • 打赏
  • 举报
回复
两个文件,指的是那两个文件?

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧