gpt4 book ai didi

java - spring webflow 无法访问mvc beans

转载 作者:行者123 更新时间:2023-11-30 11:41:47 26 4
gpt4 key购买 nike

我正在尝试在以下 Web 流程中使用一些 @Service 注释类(是的,使用 mvc:annotation-driven):

管理流.xml

<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd" start-state="start" >



<view-state id="start" view="Userview.jsp" >

<on-render>

<set name="flowScope.users"
value="UserService.getUsers()">
</set>
</on-render>
</view-state>
<bean-import resource="Manage-Beans.xml"/>
</flow>

Manage-Beans.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean class="com.dproductions.test.Service.SiteService" id="SiteService" />
<bean class="com.dproductions.test.Service.CustomerService" id="CustomerService" />
<bean class="com.dproductions.test.Service.UserService" id="UserService" />

</beans>

尝试到达流程时,我得到以下堆栈跟踪:http://pastebin.com/QmCXe45Y

归结为 Webflow 无法访问指定的包。但它没有给出 'ClassNotFoundException' ,这让我有点困惑。

欢迎提出任何建议。

此外,我的 servlet 上下文在这里找到:Servlet-context

我已经与这个问题抗争了一个多星期了。

编辑

我希望能够像在 This Example 中使用的那样使用我的 bean ,在 Action 状态下,bean 被 Spring MVC 直接拾取/管理。bean 是否必须在 applicationcontext 中声明(并且可序列化?)?使用 xml 符号?

最佳答案

如果我改变

<set> 

朝着一个

<evaluate expression>

并且在文件 Manage-Beans.xml 中定义了 beans,它就可以工作了。

但那样我必须定义同一个 bean 两次,因为它曾经被 pkg-search 注释拾取,然后在 web-flow 中再次被拾取。我想要现成的 bean 。

Spring web flow 确实会重新创建/实例化 bean。您可以引用属性,在 web-flow beans 导入文件中使用 beans Autowiring 它们,但这就像一个新的上下文,不知道现有的 beans。(使用事件进入流程和普通上下文文件。)

关于java - spring webflow 无法访问mvc beans,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12130766/

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