您的位置:首页 > 编程语言 > Java开发

spring.net依赖注入到Web页面

2009-07-15 08:49 477 查看
1. 添加Spring的SectionGroup

<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.WebContextHandler, Spring.Web"/>
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core"/>
</sectionGroup>

2. 添加HttpHandler配置

<add verb="*" path="*.aspx" type="Spring.Web.Support.PageHandlerFactory, Spring.Web"/>

3. 添加HttpModule配置(如果不添加的话,会有异常)

<add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>

4. 最后配置如何依赖注入

<spring>
<context>
<resource uri="config://spring/objects"/>
</context>
<objects xmlns="http://www.springframework.net">
<object type="Default.aspx">
<property name="Service" ref="myService"/>
</object>
<object id="myService" type="Services.MyService, Services">
</object>
</objects>
</spring>

这是一个关于spring.net学习的一个网站:

http://www.springframework.net/index.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: