ui:include src 属性的 EL 在复合组件中解析为 null
我有如下复合组件:
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:cc="http://java.sun.com/jsf/composite"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:c="http://java.sun.com/jsp/jstl/core">
<cc:interface>
<cc:attribute name="path" shortDescription="Page Title" type="String"/>
</cc:interface>
<cc:implementation>
<ui:include src="#{cc.attrs.path}"/>
</cc:implementation>
</html>
上述代码的问题是 #{cc.attrs.path}
已解析为 null。如果 src 是硬编码的,那么 ui:include 就可以正常工作。
尝试使用 h:outputText
检查 #{cc.attrs.path}
并且路径显示正确,这意味着仅在 ui:include
的情况下EL没有解决。有什么帮助吗?
I have composite component as below:
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:cc="http://java.sun.com/jsf/composite"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:c="http://java.sun.com/jsp/jstl/core">
<cc:interface>
<cc:attribute name="path" shortDescription="Page Title" type="String"/>
</cc:interface>
<cc:implementation>
<ui:include src="#{cc.attrs.path}"/>
</cc:implementation>
</html>
Problem with above code is #{cc.attrs.path}
is resolved to null. If src
is hardcoded then ui:include
works fine.
Tried checking #{cc.attrs.path}
with h:outputText
and path is displayed correctly, that means only in case of ui:include
EL is not resolved. Any help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这段代码在我的电脑上运行得很好。无论如何,EL 都已解决,但我认为包含失败,因为您尝试包含的文件格式错误或不存在。
也许您可以告诉我们您尝试包含哪种文件,然后给我们该文件的一部分?
This code works just fine on my computer. The EL is resolved in any case, but I think the include failed because the file you try to include is malformed, or does not exist.
Maybe you could tell us what kind of file you try to include, and then give us a portion of this file ?