DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> AJAX入門 >> AJAX詳解 >> ajax與spring結合
ajax與spring結合
編輯:AJAX詳解     

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>

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved