gpt4 book ai didi

spring - 在 Spring Boot 中找不到带有 @FacesComponent 的 JSF 自定义组件

转载 作者:IT老高 更新时间:2023-10-28 13:55:39 25 4
gpt4 key购买 nike

我想创建一个自定义 JSF 2.0 组件,但无法让它工作。我的组件是这样定义的:

 @FacesComponent(value = "myCustomComponent")
public class CommaSeperatedOutput extends UIComponentBase { ... }

标签库如下所示:

 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<facelet-taglib 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-facelettaglibrary_2_0.xsd" version="2.0">
<namespace>http://www.company.com/tags</namespace>
<tag>
<tag-name>custom</tag-name>
<component>
<component-type>myCustomComponent</component-type>
</component>
</tag>
</facelet-taglib>

我的 faces-config 如下所示:

<faces-config version="2.0" 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-facesconfig_2_0.xsd">
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>
</faces-config>

我收到以下错误:

SEVERE: JSF1068: Component with componenttype myCustomComponent could not be instantiated.
javax.faces.FacesException: Expression Error: Named Object: myCustomComponent not found.

不确定它是否重要,但我在这里使用 Spring 3.1 和 JSF 2.1。所以依赖是由 Spring 管理的。

知道这里发生了什么吗?

最佳答案

[这里是移 Action 者的解决方案]

似乎 Spring 是这里的坏人。我已经从组件中删除了注释 @FacesComponent(value = "myCustomComponent") 并在我的 faces-config 中定义它,如下所示:

<component>
<component-type>myCustomComponent</component-type>
<component-class>com.company.jsf.component.CommaSeperatedOutput</component-class>
</component>

现在可以了。

关于spring - 在 Spring Boot 中找不到带有 @FacesComponent 的 JSF 自定义组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9684402/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com