首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

关于spring配置文件中bean的id的有关问题

2012-04-16 
关于spring配置文件中bean的id的问题请各位帮我看一下我这个配置文件有问题吗?XML code?xml version1.0

关于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>

热点排行