溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Buffalo 2.0如何整合spring

發(fā)布時間:2021-12-24 10:31:16 來源:億速云 閱讀:162 作者:小新 欄目:編程語言

小編給大家分享一下Buffalo 2.0如何整合spring,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!

Spring是當(dāng)前最流行的輕量級容器,Buffalo對它進(jìn)行了支持。Spring中任意一個配置過的bean, 都可以通過簡單的配置被暴露為buffalo服務(wù)。 以下簡單介紹下Buffalo2.0集成Spring的配置。

1.       web.xml配置:

<display-name>

             Buffalo Web Remoting Demostration Application

      display-name>

      <context-param>

             <param-name>contextConfigLocationparam-name>

             <param-value>/WEB-INF/applicationContext.xmlparam-value>

      context-param>

      <servlet>

             <servlet-name>bfappservlet-name>

             <servlet-class>

                    net.buffalo.web.servlet.ApplicationServlet

             servlet-class>

      servlet>

      <servlet>

             <servlet-name>contextservlet-name>

             <servlet-class>

                    org.springframework.web.context.ContextLoaderServlet

             servlet-class>

             <load-on-startup>1load-on-startup>

      servlet>

      <servlet-mapping>

             <servlet-name>bfappservlet-name>

             <url-pattern>/bfapp/*url-pattern>

servlet-mapping>

2.       SpringapplicationContext.xml配置:

<bean id=" yourService "

      class="xxx.service.yourService ">bean>

<bean name="buffaloConfigBean"

       class="net.buffalo.service.BuffaloServiceConfigurer">

       <property name="services">

           <map>

               <entry key="yourService">

                   <ref bean=" yourService " />

               entry>

               <!-- oterh entries... --&gt

           map>

       property>

bean>

通過以上配置后,開發(fā)者不用再配置buffalo-service.properties文件了,使用applicationContext.xml替代之.其中引用到的bean可以是任意被Spring托管的bean。在web頁面的調(diào)用卻不需要做什么改變。如:

<script language="javascript" src="js/prototype.js">script>

      <script language="javascript" src="js/buffalo.js">script>

     

      <script type="text/javascript">

      var END_POINT="<%=request.getContextPath()%>/bfapp";

      var buffalo = new Buffalo(END_POINT);  

     

      function xxx(){

buffalo.remoteCall("yourService. method", [], function(reply) {

             alert(reply.getResult());

          })

      }

   script>

看完了這篇文章,相信你對“Buffalo 2.0如何整合spring”有了一定的了解,如果想了解更多相關(guān)知識,歡迎關(guān)注億速云行業(yè)資訊頻道,感謝各位的閱讀!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI