美文网首页
对应网址

对应网址

作者: kingandyoga | 来源:发表于2016-05-31 15:01 被阅读32次

对应网址

http://10.173.17.104:8080/Server

User:

http://10.173.17.104:8080/Server/getUsers

1 成功

2 失败

http://10.173.17.104:8080/Server/newUsers

返回:

1 成功

2 用户名已经存在

http://10.173.17.104:8080/Server/userLogin

返回:

1 登陆成功

2 密码错误

3 用户名不存在


Goods:

http://10.173.17.104:8080/Server/getGoods

http://10.173.17.104:8080/Server/newGoods

http://10.173.17.104:8080/Server/updateGoods

http://10.173.17.104:8080/Server/deleteGoods


Activities:

http://10.173.17.104:8080/Server/getActivities

http://10.173.17.104:8080/Server/newActivities

http://10.173.17.104:8080/Server/updateActivities

http://10.173.17.104:8080/Server/deleteActivities


UploadPic

http://10.173.17.104:8080/Server/getPic

http://10.173.17.104:8080/Server/uploadPic


app发出请求代码


import java.io.DataOutputStream;
import java.io.ObjectInputStream;
import java.net.HttpURLConnection;
import java.net.URL;

public class sendToServer {
    
    String url_string = "";
    public void send(String json){
        URL url = null;
        HttpURLConnection connection = null;
        try {
            
            url = new URL(url_string);
            connection = (HttpURLConnection) url
                    .openConnection();
            connection.setDoInput(true);
            connection.setDoOutput(true);
            connection.setConnectTimeout(10000);
            connection.setReadTimeout(10000);
            connection.setRequestMethod("POST");// 设置为post方法
            
            // 输出流
            DataOutputStream outobj = new DataOutputStream(
                    connection.getOutputStream());
            
            Gson gson = new Gson();
            User user = new User();
            user.setId("aa");
            user.setClassmark("classmark");
            user.setEmail("aaa");
            user.setPassword("aaa");
            user.setPhone("111");
            String userson = gson.toJson(user);
            
            // 先写入标志服 在写 json 那么读的时候 先读取json 再读取标志
            outobj.writeInt(3);
            outobj.writeUTF(userson);

            outobj.flush();
            
            outobj.close();
            
            
            // 输入流 服务器传回来的东西
            ObjectInputStream ois = new ObjectInputStream(
                    connection.getInputStream());
            String result = (String) ois.readObject();
            ois.close();
            connection.disconnect();
            
        }catch(Exception e){
            
        }
    }

}


服务器发出反馈的代码

//反过来的代码 

            DataInputStream ios = null;
            ios = new DataInputStream(request.getInputStream());
            ObjectOutputStream oos = null;
            oos = new ObjectOutputStream(response.getOutputStream());       
            //读取标志符
            int i = ios.readInt();
            
            System.out.println(i);
            
            User user = new User();
            user.setId("hahaha");
            user.setPassword("1234");
            //user.setIdentity("1111");
            
            Gson gson = new Gson();
            String string = gson.toJson(user);
            
                
            //回传对象
            oos.writeObject(string);
            


相关文章

  • 对应网址

    对应网址 http://10.173.17.104:8080/Server User: http://10.173...

  • django

    Django目录结构: urls.py:网址入口,关联到对应的Views.py中的一个函数,访问网址对应的函数。 ...

  • Django主要模块

    urls.py网址入口,关联到对应的views.py中的一个函数(或者generic类),访问网址就对应一个函数。...

  • PY-Django的布局

    1.urls.py网址的入口,关联到对应的views.py中的函数,访问网址就对应一个函数2.views.py处理...

  • 【Python爬虫】正则爬取糗事百科

    实验目的:获取糗事百科网页上的段子 思路 1)分析各个页面间的网址规律,构造网址变量 对应的网址:https://...

  • windows下载安装anaconda3.6图文教程

    1. 进入anaconda官方网址 Downloads - Anaconda 2.点击对应Python版本以及对应...

  • 高性能短链(短网址)算法

    短网址介绍 短网址现在可以说是随处可见,很多短信内部都会包含短网址,点击短网址链接可以直接跳到对应的长链接地址,背...

  • Xcode版本低于测试机系统版本问题

    https://github.com/filsv/iPhoneOSDeviceSupport 进入网址,下载对应支...

  • 三、网址的对应与委派

    Django的MTV架构在说明网址委派的细节之前,我们必须先了解Django运行架构是什么,经常可以听到MVC框架...

  • prometheus简单环境搭建

    安装prometheus 网址:https://prometheus.io/download/ 下载对应版本但是真...

网友评论

      本文标题:对应网址

      本文链接:https://www.haomeiwen.com/subject/rqgcdttx.html