freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

restlet開發(fā)實例(一)基于jax-rs的rest服務(wù)(編輯修改稿)

2025-02-12 05:21 本頁面
 

【文章內(nèi)容簡介】 */urlpattern/servletmapping啟動tomcat沒報錯的話,說明你配置正常。將Restlet服務(wù)當(dāng)做單獨的Java 程序進(jìn)行部署創(chuàng)建類 RestJaxRsServer,代碼如下:public static void main(String[] args) throws Exception {Component ponent = new Component()。().add(, 8085)。().attach(new RestJaxRsApplication(null))。()。}該類中創(chuàng)建一個新的 Http Server,添加監(jiān)聽端口8085。將RestJaxRsApplication加入到 Http Server 中。運(yùn)行該代碼,下圖說明你啟動成功。三、測試Restlet服務(wù)瀏覽器模式訪問xml數(shù)據(jù) ://localhost:8085/RestService/student/1/xml訪問json數(shù)據(jù) ://localhost:8085/RestService/student/1/json 提示下載數(shù)據(jù),下載后打開數(shù)據(jù)內(nèi)容為{“name”:”Steven”,”id”:1,”age”:0,”sex”:1,”clsId”:201001}如果是獨立部署的話,直接訪問:://localhost:8085/student/1/xml 即可。Restlet自帶了客戶端測試代碼,目前提供了jee、webkit、android等版本,調(diào)用rest服務(wù),非常方便。新建Client類,代碼如下://public static String url=”://localhost:8085/“。public static String url=”://localhost:8085/RestService/“。public static void testXml() {ClientResource client = new ClientResource(url+”student/1/xml”)。try {(().getText())。} catch (ResourceException e) {// TODO Autogenerated catch block()。} catch (IOException e) {// TODO Autogenerated catch block()。}}public static void testJson() {ClientResource client = new ClientResource(url+”student/1/json”)。try {(().getText())。} catch (ResourceException e) {// TODO Autogenerated catch block()。} catch (IOException e) {// TODO Autogenerated catch block()。}}通過junit測試代碼分別輸出:四、實現(xiàn)對Rest服務(wù)的PUT,POST,DELETE方法。到現(xiàn)在我們已經(jīng)完成一個基本的Rest搭建,并且實現(xiàn)了GET方法。REST定義了4個基本方法:可以參見 REST架構(gòu)概述 。POST方法在StudentResource中加入該方法,用于添加一個Student:@POST@Path(“add”)public String addStudent(Representation entity) { F
點擊復(fù)制文檔內(nèi)容
環(huán)評公示相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1