【问题标题】:Not able to use attributes in Custom-tags jsp无法在自定义标签 jsp 中使用属性
【发布时间】:2013-06-27 15:11:55
【问题描述】:

我正在jsp 中开发一个自定义标记处理程序,它接受一个名为“yourname”的属性。 .tld 文件和标记处理程序文件包含相同的属性名称(我也检查了大小写)。但不知何故,当我运行网络应用程序时,我得到了一个例外。异常消息显示“根据 TLD,属性 yourname 对标签 sayhello 无效”。

这是tld文件中的标签信息。

<tag>
<name>sayhello</name>
<tag-class>check.PrintTagHandler</tag-class>
<body-content>scriptless</body-content>
<attribute>yourname</attribute>
</tag>

这是 bean 中的属性名称。

private String yourname;

这是电话

<hello:sayhello yourname="ABC"/>

标签声明:

<%@taglib prefix="hello" uri="/WEB-INF/tlds/newtag_library2"%>

一切似乎都是正确的,但我得到了例外。

请帮忙。

【问题讨论】:

  • yourname 属性的 getter setter 是否到位?
  • @BhushanKawadkar:是的,它们就位。当我不使用属性时,它工作正常。它正在打印 Welcome null。问题是当我使用属性时。

标签: jsp jstl custom-tag


【解决方案1】:

对不起大家..

tld 应该是这样的。

<attribute>
<name>yourname</name>    
<required>true</required>
<rtexprvalue>false</rtexprvalue>    
</attribute>

而不是

<attribute>yourname</attribute>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-01-12
    • 2016-10-22
    • 1970-01-01
    • 2011-03-09
    • 2011-12-13
    • 2010-09-18
    • 2017-08-30
    • 1970-01-01
    相关资源
    最近更新 更多