0

我正在尝试在 myTld.tld 文件中定义一个函数,例如

<?xml version="1.0" encoding="UTF-8"?>
<taglib version="2.1" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd">

<tlib-version>1.0</tlib-version>
<short-name>customFunctions</short-name>
<uri>/WEB-INF/tags/myTld.tld</uri>

<function>
   <description>
       my Desc
   </description>
   <name>isActive</name>
   <function-class>com.Functions</function-class>
   <function-signature>boolean isActive()</function-signature>
 </function>
</taglib>

从 El 脚本我打电话给喜欢

<%@ taglib prefix="customFunctions" uri="/WEB-INF/tags/myTld.tld"%>
${customFunctions:isActive()}

每次我这样做,我都会得到

Invalid syntax for function signature in TLD.  Tag Library: customFunctions, Function: isActive
4

2 回答 2

1

改变

<function-signature>boolean isActive()</function-signature>

<function-signature>java.lang.Boolean isActive()</function-signature>

也改为<description>my Desc</description>一行。这也可能是(可能不是)问题。

于 2013-02-28T23:15:42.280 回答
0

There seems to be no issue with respect to function-signature. Description can be broken to multiple line as long as they are closed in the proper tag structure. Even the return type can be given as primitive.

But thanks for your support. I just tried after few hour the same thing and it ran successfully. Not sure why Tomcat gave me strange error(Even after multiple compilation and redeployment). Though i feel the Tomcat should be little more smart enough to tell the exact error when it says signature is wrong.The tomcat log also did not gave me any other information.

于 2013-03-01T22:46:27.950 回答