WebService Resetful框架 spring-bean的配置

最近再写Restful接口,我推荐一个不错的restful学习demo,

http://my.oschina.net/jiyayun/blog/146446

目前大多j2ee项目是spring接管service层和dao层,

前端时间一直头疼restful中无法获取bean的问题,只要打通这个“任督二脉”,

接下的来的开发任务都能如鱼入水。

先看 WEB-INF/restlet-servlet.xml 中的配置;

<?xml version="1.0"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">

	<bean name="root" class="org.restlet.ext.spring.SpringRouter">
		<property name="attachments">
			<map>
				<entry key="/query">
					<bean class="org.restlet.ext.spring.SpringFinder">
						<lookup-method name="create" bean="QueryResource" />
					</bean>
				</entry>
			</map>
		</property>
	</bean>

	<bean id="QueryResource" class="com.restful.QueryResource"
		scope="prototype">
		<property name="serviceLogService" ref="serviceLogService" />
		<property name="serviceAppService" ref="serviceAppService" />
	</bean>

</beans>

其中 root"bean存放map含有众多entry,拦截对应的请求链接。

关键在与倒数 3,4行,注入的serviceLogServiceserviceAppService这两个传统的service层bean.

然后对应的java代码也加入2bean的引用,

        @Autowired
	static ServiceLogService serviceLogService;

	@Autowired
	static ServiceAppService serviceAppService;







  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值