我认为您不能在标签上指定类型。您可以使用自定义 el 函数来做到这一点:
<?xml version="1.0" encoding="UTF-8" ?>
<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">
<tlib-version>1.0</tlib-version>
<short-name>shortname</short-name>
<uri>http://some/uri</uri>
<function>
<name>testMethod</name>
<function-class>
somePackage.TestFunction
</function-class>
<function-signature>
java.lang.String testMethod( java.util.HashMap)
</function-signature>
</function>
</taglib>
对应类:
public class TestFunction {
public static String testMethod(HashMap<?, ?> map) {
return map.toString();
}
}