日期:2014-05-18  浏览次数:20679 次

JSP自定义标签问题,急!!!!!!
出错信息:org.apache.jasper.JasperException:   /testtld.jsp(11,0)   Unable   to   load   tag   handler   class   "Hello "   for   tag   "mytag:ConectJob "

该class放了在web-inf下的classes下和web-inf下都有

tld文件放了在web-inf下,同上信息,jsp应该调用tld成功了吧?

我想知道问题出在哪,还有就是有的说把class放在文件夹class下,有的说是classes文件夹下,我想知道,tld文件怎么定位class文件的?在 <tag-class> </tag-class> 中好象都没定义路径

------解决方案--------------------
tld中有定义路径的:
<tagclass>
org.caexpo.common.tag.TTTag
</tagclass>

class会自己编译生成的。你看下路径对了没有,和自己定义的

class是在web-inf下的classes的
------解决方案--------------------
开发自定义标签分为两个步骤:
A.实现自定义标签功能的java类的编写
B.TLD文件的编写
例:在页面显示时间的标签
//功能java 类
package com.mju.tagclass;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
public class ShowCurrentDatetimeTag extends TagSupport {
public int doEndTag()throws JspException
{
Date currentDateTime;
DateFormat df=new SimpleDateFormat( "yyyy-MM-dd hh:mm:ss ");
currentDateTime=new Date();
try {
pageContext.getOut().print(df.format(currentDateTime));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return EVAL_PAGE;
}

}
//struts.tld编写
<?xml version= "1.0 " encoding= "UTF-8 "?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN " "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd ">
<taglib>
<tlibversion> 1.2 </tlibversion>
<jspversion> 1.1 </jspversion>
<shortname> customTag </shortname>
<tag>
<name> currentDatetime </name>
<tagclass> com.mju.tagclass.ShowCurrentDatetimeTag </tagclass>
</tag>
</taglib>
//使用test.jsp
<%@ page language= "java " contentType= "text/html;charset=gb2312 "%>
<%@ taglib uri= "WEB-INF/struts-time.tld " prefix= "customTag "%>
......
当前的时间是: <customTag:currentDatetime/>
.....

------解决方案--------------------
我也是定义出了错,你可以照那本 < <JSP2.0技术手册> > ,上面写得很详细
------解决方案--------------------
^_^,我的论坛就用用到jsp自定义标签的
http://www.yyhweb.com
提供论坛源代码下载