温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Buffalo 2.0如何整合spring

发布时间:2021-12-24 10:31:16 来源:亿速云 阅读:149 作者:小新 栏目:编程语言

小编给大家分享一下Buffalo 2.0如何整合spring,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!

Spring是当前最流行的轻量级容器,Buffalo对它进行了支持。Spring中任意一个配置过的bean, 都可以通过简单的配置被暴露为buffalo服务。 以下简单介绍下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>

通过以上配置后,开发者不用再配置buffalo-service.properties文件了,使用applicationContext.xml替代之.其中引用到的bean可以是任意被Spring托管的bean。在web页面的调用却不需要做什么改变。如:

<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”有了一定的了解,如果想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI