Spring的集成幾乎異常簡單,只需要更改配置文件而已.
頁面的代碼不用動,例如
doc.simple-spring.JSP
<script language="Javascript">var springEndPoint="<%=request.getContextPath()%>/remoting/Spring-buffalo";function pageMethod() { var buffalo = new Buffalo(springEndPoint); buffalo.remoteCall("yourObject.yourMethod",[], function(reply) { var Obj = reply.getResult(); })}</script>
web部署描述文件
web.XML
<?XML version="1.0" encoding="UTF-8"?><!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "
以前的buffalo-service.propertIEs文件則不用,applicationContext.XML所替代之.其中引用到的bean可以是任意被Spring托管的bean.這個Controller可以被任意任意方式的ServletDispather調用.
applicationContext.XML
<beans> <bean name="simpleService" class="net.buffalo.demo.simple.SimpleService"></bean> <bean name="numberService" class="net.buffalo.demo.numberguess.NumberGuessService"></bean> </beans>
remoting-servlet.XML
<beans> <bean name="/Spring-buffalo" class="net.buffalo.spring.BuffaloServiceExporter"> <property name="services"> <map> <entry key="simpleService"> <ref bean="simpleService"/> </entry> <entry key="numberService"> <ref bean="numberService"/> </entry> </map> </property> </bean> </beans>