spring Struts2整合時一個配置問題

appllicationContext.xml中配置信息:
    <bean id="chatService" class="forSpr.ChatServiceImpl"/>
    <bean id="chatActionTest" class="forSpr.ChatAction" scope ="prototype">
        <property name="chatService">
            <ref local="chatService"/>
        </property>
    </bean>

struts配置文件:
    <package name="Struts2_IoC" extends="struts-default">
        <action name="Chatw" class="forSpr.ChatAction">
            <result>/forSpr/UserList.jsp</result>
        </action>
    </package>

A:則正常顯示;
B:刪除appllicationContext.xml中的<bean>信息,可以正常啓動但提示NullPointerException,變量沒有初始化;
C:從配置信息中似乎看不出對Chatw.action訪問與app*.xml中的<bean>配置信息有任何關係,但卻可以正常訪問。
D:將struts配置文件改爲以下也可以正常訪問:
    <package name="Struts2_IoC" extends="struts-default">
        <action name="Chatw" class="chatActionTest">
            <result>/forSpr/UserList.jsp</result>
        </action>
    </package>
可以看出只是改變了class的值。
E:而struts.properties文件中的struts.objectFactory=spring屬性可有可無,對系統不產生影響。
F:結論:spring與struts2的整合系統裏,系統會針對類進行**自動裝配**(無手動顯式的裝配配置信息)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章