SpringWebFlow&;Java服务器在流期间面向@ManagedProperty注入始终为空
我已经成功地将JSF与SpringWebFlow和PrimeFaces集成,但是@ManagedProperty的注入在我的web流中总是空的,但是使用@Autowired注释注入是有效的我想知道为什么@ManagedProperty不起作用,但@Autowired起作用。 我的环境:Spring3.2.1.RELEASE、JSF2.2.4、PrimeFaces3.0 UserBean类:SpringWebFlow&;Java服务器在流期间面向@ManagedProperty注入始终为空,java,spring,jsf,spring-webflow,managed-property,Java,Spring,Jsf,Spring Webflow,Managed Property,我已经成功地将JSF与SpringWebFlow和PrimeFaces集成,但是@ManagedProperty的注入在我的web流中总是空的,但是使用@Autowired注释注入是有效的我想知道为什么@ManagedProperty不起作用,但@Autowired起作用。 我的环境:Spring3.2.1.RELEASE、JSF2.2.4、PrimeFaces3.0 UserBean类: @ManagedBean public class UserBean implemen
@ManagedBean
public class UserBean implements Serializable {
@ManagedProperty(value="#{messageBean}")
private MessageBean messageBean;
public MessageBean getMessageBean() {
return messageBean;
}
public void setMessageBean(MessageBean messageBean) {
this.messageBean = messageBean;
}
}
@ManagedBean(name = "messageBean")
public class MessageBean implements Serializable {
public String getMessage(){
return "Hello, " + name;
}
}
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>
<!-- Executes flows: the central entry point into the Spring Web Flow system -->
<flow-executor id="flowExecutor">
<flow-execution-listeners>
<listener ref="facesContextListener"/>
</flow-execution-listeners>
</flow-executor>
<!-- The registry of executable flow definitions -->
<flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices" base-path="/WEB-INF/flows">
<flow-location-pattern value="/**/flow.xml" />
<flow-location id="parent-flow" path="parent-flow.xml"/>
</flow-registry>
<!-- Configures the Spring Web Flow JSF integration -->
<faces:flow-builder-services id="flowBuilderServices" development="true" />
<!-- A listener to create and release a FacesContext -->
<beans:bean id="facesContextListener" class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener"/>
MessageBean类:
@ManagedBean
public class UserBean implements Serializable {
@ManagedProperty(value="#{messageBean}")
private MessageBean messageBean;
public MessageBean getMessageBean() {
return messageBean;
}
public void setMessageBean(MessageBean messageBean) {
this.messageBean = messageBean;
}
}
@ManagedBean(name = "messageBean")
public class MessageBean implements Serializable {
public String getMessage(){
return "Hello, " + name;
}
}
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>
<!-- Executes flows: the central entry point into the Spring Web Flow system -->
<flow-executor id="flowExecutor">
<flow-execution-listeners>
<listener ref="facesContextListener"/>
</flow-execution-listeners>
</flow-executor>
<!-- The registry of executable flow definitions -->
<flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices" base-path="/WEB-INF/flows">
<flow-location-pattern value="/**/flow.xml" />
<flow-location id="parent-flow" path="parent-flow.xml"/>
</flow-registry>
<!-- Configures the Spring Web Flow JSF integration -->
<faces:flow-builder-services id="flowBuilderServices" development="true" />
<!-- A listener to create and release a FacesContext -->
<beans:bean id="facesContextListener" class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener"/>
faces config.xml:
@ManagedBean
public class UserBean implements Serializable {
@ManagedProperty(value="#{messageBean}")
private MessageBean messageBean;
public MessageBean getMessageBean() {
return messageBean;
}
public void setMessageBean(MessageBean messageBean) {
this.messageBean = messageBean;
}
}
@ManagedBean(name = "messageBean")
public class MessageBean implements Serializable {
public String getMessage(){
return "Hello, " + name;
}
}
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>
<!-- Executes flows: the central entry point into the Spring Web Flow system -->
<flow-executor id="flowExecutor">
<flow-execution-listeners>
<listener ref="facesContextListener"/>
</flow-execution-listeners>
</flow-executor>
<!-- The registry of executable flow definitions -->
<flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices" base-path="/WEB-INF/flows">
<flow-location-pattern value="/**/flow.xml" />
<flow-location id="parent-flow" path="parent-flow.xml"/>
</flow-registry>
<!-- Configures the Spring Web Flow JSF integration -->
<faces:flow-builder-services id="flowBuilderServices" development="true" />
<!-- A listener to create and release a FacesContext -->
<beans:bean id="facesContextListener" class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener"/>
org.springframework.web.jsf.el.SpringBeanFacesELResolver
webflow.xml:
@ManagedBean
public class UserBean implements Serializable {
@ManagedProperty(value="#{messageBean}")
private MessageBean messageBean;
public MessageBean getMessageBean() {
return messageBean;
}
public void setMessageBean(MessageBean messageBean) {
this.messageBean = messageBean;
}
}
@ManagedBean(name = "messageBean")
public class MessageBean implements Serializable {
public String getMessage(){
return "Hello, " + name;
}
}
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>
<!-- Executes flows: the central entry point into the Spring Web Flow system -->
<flow-executor id="flowExecutor">
<flow-execution-listeners>
<listener ref="facesContextListener"/>
</flow-execution-listeners>
</flow-executor>
<!-- The registry of executable flow definitions -->
<flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices" base-path="/WEB-INF/flows">
<flow-location-pattern value="/**/flow.xml" />
<flow-location id="parent-flow" path="parent-flow.xml"/>
</flow-registry>
<!-- Configures the Spring Web Flow JSF integration -->
<faces:flow-builder-services id="flowBuilderServices" development="true" />
<!-- A listener to create and release a FacesContext -->
<beans:bean id="facesContextListener" class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener"/>
我还有文件flow.xml和view.xhtml,因为我使用PrimeFaces将SpringWebFlow与JSF集成在一起
WEB-INF/flows/ajax jsf/flow.xml:
<var name="userBean" class="org.springframework.samples.webflow.ajax.UserBean" />
<var name="messageBean" class="org.springframework.samples.webflow.ajax.jsf.MessageBean" />
<view-state id="view">
<transition on="suggest" >
<evaluate expression="userBean.createEmailSuggestion(flowRequestContext)"
result="viewScope.emailSuggestion" />
</transition>
</view-state>
你知道我的@ManagedProperty注入失败的原因吗?如果我用@Autowired替换@ManagedProperty,我可以看到该对象已创建,但@ManagedProperty始终为空 我在这里只看到jsf托管bean,而不是与spring相关的东西尝试下载这个示例:然后使用@ManagedProperty注入一些东西。总是空的。。。我真的不知道为什么…对不起,这太多的工作了,但我认为这是一个非常奇怪的错误,这是一个学习新东西的好机会…为我学习新东西?我认为使用Spring向后一步,就像使用JSF托管bean一样。我使用CDI已有几年了。。。