自定义tag时jsp报错incompatible object argument for function call

fourfire29 2004-01-15 12:10:27
按照例子敲的,不知道为什么!!
...全文
198 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
fourfire29 2004-01-29
  • 打赏
  • 举报
回复
按 stonecsdn(东东)改了之后,还是不行呀!!!
fourfire29 2004-01-15
  • 打赏
  • 举报
回复
没什么呀
java:
public class FirstTag extends TagSupport
{
/* (非 Javadoc)
* @see javax.servlet.jsp.tagext.Tag#doEndTag()
*/
public int doStartTag() throws JspException
{
// get the locale of the client and create an appropriate date format
Locale loc = pageContext.getRequest().getLocale();
DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM, loc);
try
{
// and write out the formatted date to the page
pageContext.getOut().write(df.format(new Date()));
}
catch (java.io.IOException ioe)
{
throw new JspTagException(ioe.getMessage());
}
// and skip evaluating the body of the tag (as there shouldn't be one)
return SKIP_PAGE;
}
}
my-tag.lib
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib
PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
"http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">

<taglib>

<tlib-version>1.0</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>simple</short-name>
<description>Examples for the Simple Tags chapter</description>

<tag>
<name>date</name>
<tag-class>com.chinsoft.mytag.FirstTag</tag-class>
<body-content>empty</body-content>
<description>Inserts the current date into the page</description>
</tag>

</taglib>
jsp:
<%@ page language="java" pageEncoding="GB2312" %>


<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/my-tag.tld" prefix="simple" %>
<!DOCTYPE HTML PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title>Lomboz JSP</title>

</head>
<body bgcolor="#FFFFFF">

<simple:date/>
寒冬 2004-01-15
  • 打赏
  • 举报
回复
incompatible object argument for function call

是说你调用的函数中参数不匹配
stonecsdn 2004-01-15
  • 打赏
  • 举报
回复
修改一处即可。
throw new JspTagException(ioe.getMessage());
}
// and skip evaluating the body of the tag (as there shouldn't be one)
return SKIP_PAGE;//这应该是return SKIP_BODY;
}
}

81,092

社区成员

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

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