栏目导航
热点推荐
- 流行的70个AJAX演示及下载
- 20个Ajax关键议题
- AJAX技术在PHP开发中的简单应用
- 如何选择使用AJAX的最佳时机
- 一日精通Ajax技术
- [四天学会ajax] 学习Ajax教程第
- [四天学会ajax] 学习Ajax教程第
- ajax的server部分(php版)
- 在Ajax 应用程序中实现数据之间
- 解决AJAX 跨域访问完整解决方案
- Ajax获取页面被缓存的解决方案
- ajax检测用户名
阅览排行
ajax与spring结合
www.jz123.cn 2008-10-31 来源: 中国建站 袁袁整理 我要投递新闻
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" "http://java.sun.com/dtd/web-app_2_3.dtd"><web-app> <display-name>Buffalo Web Remoting Demostration Application</display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/applicationContext.xml </param-value> </context-param> <servlet> <servlet-name>context</servlet-name> <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet> <servlet-name>remoting</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>4</load-on-startup> </servlet> <servlet-mapping> <servlet-name>remoting</servlet-name> <url-pattern>/remoting/*</url-pattern> </servlet-mapping> </web-app>
以前的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>
上一篇:[四天学会ajax] 学习Ajax教程第三天,Ajax 中的高级请求和响应 下一篇:Ajax光环背后的隐患