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;

相关文章

1.使用ajax调用varxhr;functioninvoke(){if(window.ActiveXO...
               好不容易把WebService服务器...
1新建一个工程项目用来做服务端增加一个MyService1类文件pac...
packagecom.transsion.util;importjava.io.BufferedReader;i...
再生产wsdl文件时重写描述文件1usingSystem;2usingSystem.Co...
一般情况下,使用eclipse自带的jax-ws生成webservice会自动生...