日期:2014-05-19  浏览次数:20662 次

关于spring配置文件中bean的id的问题
请各位帮我看一下我这个配置文件有问题吗?
XML code
<?xml version="1.0" encoding="UTF-8"?>
<beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

    
    <bean id="loginBizImpl" class="com.ordermeals.biz.impl.loginBizImpl">
    </bean>
    
    <bean id="indexAction" class="com.ordermeals.action.indexAction">
        <property name="loginbiz" ref="loginBizImpl"/>
    </bean>
</beans>

在我这里为什么第一个bean的id必须要和那个property的name完全一样才有效,根据我的理解那个id可以随便定义的吧,只要下面的ref和它保持一致就可以了吧。但事实我的就不行,有没有哪位知道这是什么原因。

------解决方案--------------------
因为你类里面定义的loginBizImpl对象的名称也叫loginBizImpl。。所以你就补行
------解决方案--------------------
从来没有出现这个情况<property name="loginbiz" ref="loginBizImpl"/>红色的是set方法的,蓝色的是bean的Id
------解决方案--------------------
你struts的配置文件的action是不是
<action name="indexAction" class="indexAction">
红色的地方是spring配置文件的Id?
</action>