ajax与spring结合


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>
http://www.javabc.com/

本文作者:



相关阅读:
全面解析Server对象
详解IE CSS Bug及解决方案
Fedora 11 Beta版体验图辑
CSS高级技巧:圆角矩形
类型File的Input按钮功能研究
windows下安装、卸载mysql服务
SQL Server数据库导入导出数据方式比较
ServerVariables集合检索预定的环境变量
Facebook的PHP代码对环境的冲击
PHP 内存缓存加速功能memcached安装与用法
网页教学网收集20个方便网页开发的工具
惊现支撑1亿pv/天的超级数据库解决方案
漫谈Windows 7对固态硬盘的优化
零命令玩转Ubuntu 8.04 之 安装篇
快速导航

Copyright © 2016 phpStudy | 皖ICP备18014864号-4