与元素类型关联的属性"method-signature"的值"cc:attribute"不得包含"<"字符



报错

属性"method-signature"的值与元素类型"cc:attribute"不能包含'<'字符。javax.faces.view.facelets.FaceletException: Error Parsing/resources/custom.xhtml: Error tracing [line: 6]

custom.xhtml

<f:view xmlns="http://www.w3.org/1999/xhtml"
xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core">
<composite:interface>
<composite:attribute method-signature="List<String> function(String param)" name="function"/>
</composite:interface>
<composite:implementation>
<p:ajax event="change" update="#{cc.attrs.function}"/>
</composite:implementation>
</f:view>

这个错误来自<String>,因为在XML中不允许在标签内使用尖括号。那么,为复合属性声明方法签名的正确方法是什么呢?它是JSF 2和Primefaces 7.0。JSF中methodexexpression的正确语法是什么?EL中是否支持泛型方法?我是否应该使用&lt;&gt;来逃避尖括号,或者可能删除泛型类型,EL将正确解析List function(String param)?

EL不支持泛型方法。此外,您必须提供完整的限定类名作为类型。所以你需要的签名是

java.util.List function(java.lang.String param)

相关内容

最新更新