今天图老师小编要跟大家分享ajax与spring结合,精心挑选的过程简单易学,喜欢的朋友一起来学习吧!
【 tulaoshi.com - Web开发 】
Spring的集成几乎异常简单,只需要更改配置文件而已.
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/webkaifa/)页面的代码不用动,例如
  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
  http://www.javabc.com/ 
  
来源:http://www.tulaoshi.com/n/20160219/1627111.html
看过《ajax与spring结合》的人还看了以下文章 更多>>