LEAP环境如何使用和配置RestService
来源:互联网 发布:买家如何避免淘宝客 编辑:程序博客网 时间:2024/06/13 16:55
Rest 服务定义:
即REST(Representational State Transfer表述性状态转移)是一种针对网络应用的设计和开发方式,可以降低开发的复杂性,提高系统的可伸缩性。
关于rest service 的详细说明请自行Google或百度
目录结构
定义服务
- 在
logic
中写一个测试的方法example_sample
(在新建方法名时建议按照开发规范来,一般是“项目名” +“_”+“功能名称”)
package com.longrise.example.BLL.Logic;import com.longrise.LEAP.Base.Logic.LEAPLogic;import com.longrise.LEAP.Base.Objects.EntityBean;public class ExampleWebLogic extends LEAPLogic{ /** * 创建EntityBean 添加数据。 * @return EntityBean */ public String example_sample(EntityBean bean){ if(bean.isNotEmpty("name")){ return bean.getString("name"); } return ""; }}
在service类中将逻辑代码曝光
package com.longrise.example;import com.longrise.LEAP.Base.Logic.LogicManager;import com.longrise.LEAP.Base.Objects.EntityBean;import com.longrise.LEAP.Base.Session.LEAPContextService;import com.longrise.example.BLL.Logic.ExampleWebLogic;public class ExampleWebService extends LEAPContextService{ /** * 创建EntityBean 添加数据。 * @return EntityBean */ public String example_sample(EntityBean bean){ ExampleWebLogic ExampleWeblogic = new ExampleWebLogic(); LogicManager.getInstance().setLogic(this,ExampleWeblogic); return ExampleWeblogic.example_sample(bean); }}
配置leap.xml
- 找到
RPCService name=“web"
; - 在
classes
中添加曝光logic
的service
类限定名<class>com.longrise.example.ExampleWebService</class>
; - 在
publishRestService
中添加要定义成restService的功能名称(service类中的)<service>example_sample</service>
;
<RPCService name='web' websites="*"> <!--定义服务类,可多个class--> <classes> <class>com.longrise.LEAP.Web.LWBPWebService</class> <class>com.longrise.example.ExampleWebService</class> </classes> <datamodules> </datamodules> <pagemodules></pagemodules> <!--定义发布的服务--> <publish> <service>*</service> </publish> <publishRestService> <service>example_sample</service> </publishRestService> </RPCService>
测试
- 项目启动 后输入 项目名称/restservices , 如 http://localhost:8080/example/restservices ,此页面是项目中所有的rest服务
- 输入参数
{"name":"lix"}
- 点击测试按钮,将显示结果页面
如果页面上显示的是你输入的 name, 恭喜你配置成功。
ajax如果调用restservice
var bean = {"name":"lix"}; $.ajax({ type :"post", url :'http://localhost:8080/example/restservices/web/example_sample/query', data :{bean:JSON.stringify(bean)}, async :false, success :function(data){ if(data != ""){ console.log(data); } } });
在成为大神的路上慢慢爬
1 0
- LEAP环境如何使用和配置RestService
- Leap Motion的环境配置(使用c#)
- leap motion VC环境配置
- Leap Motion开发第一步环境配置
- Leap Motion C++环境的配置
- Leap Motion环境配置(C++)
- 实战基于Leap Motion体感外设使用Win32(VC++)环境配置
- 使用C++开发Leap Motion应用程序——Windows下开发环境配置
- Leap Motion 入门一:VS上环境配置
- Leap Motion开发环境配置LeapmotionDevelopmentKit3.2.0+VS2013
- 在JSP环境中如何配置和使用fckeditor
- 多mysql环境(wamp和单独配置的环境同时存在)如何使用这个环境
- Leap Motion 使用OpenCV获取和显示图像
- hibernate环境配置和使用
- [Leap Motion开发系列]win32应用的环境配置[2013-11-2更新]
- linux qt 4.8 x86 arm开发环境配置(openSUSE Leap 42.1)
- Leap Motion C++开发笔记(一)下载安装及环境配置
- 如何安装和配置java环境
- struct usb_bus
- TortoiseGit 中文语言包检测不出来
- 命令模式
- C语言itoa()函数和atoi()函数详解---整数与字符互相转换C函数
- Android检测url地址是否可达
- LEAP环境如何使用和配置RestService
- 架构设计:负载均衡层设计方案(5)——LVS单节点安装
- 5-10 顺序存储的二叉树的最近的公共祖先问题 (25分)
- 301重定向
- poj3090 Visible Lattice Points(法雷级数)
- 中文字体库转换成16X16点阵 另外附上ASCII码转换8X16点阵
- 深入解读Spring Framework Web MVC(第七弹:@ModelAttribute的使用)
- QT5 获取mac地址和cpu序列号
- Redis-cli命令最新总结