在easyjweb里面可以使用spring容器来帮助管理bean:
在jweb的配置文件中加入:
<bean name="springcontainer" class="org.springframework.context.support.classpathxmlapplicationcontext"> <constructor-arg type="java.lang.string[]"> <list> <value>classpath:applicationcontext.xml</value> </list> </constructor-arg> </bean> <bean name="innerspringcontainer" class="com.easyjf.container.impl.springcontainer"> <property name="factory" ref="springcontainer" /> </bean>
其中的<list><value>classpath:dao.xml</value></list>为spring配置文件的路径,
现在暂时使用的是classpathxmlapplicationcontext。
现在在applicationcontext.xml中配置一个bean(片断):
<bean id="queryservice" class="com.easyjf.core.service.impl.queryserviceimpl"> <property name="dao"> <bean parent="basedao"> <constructor-arg> <value>java.lang.object</value> </constructor-arg> </bean> </property> </bean>
然后在action中:
private iqueryservice service; public void setservice(iqueryservice service) ...{ this.service = service; }
在action的配置中:
<module name="nesource" path="/nesource" form="" scope="request" ... <page name="edit" url="/cms/newssourceedit.html" type="template" /> <property name="service" ref="cmsmanageservice" /> ... </module>
在配置中用ref指定spring中的bean。
好,
到这里就ok了。
easyjweb会在框架初始化的时候发现spring容器并初始化,
并从其中加载需要的bean 。
闽公网安备 35060202000074号