为了账号安全,请及时绑定邮箱和手机立即绑定

用http协议建立接连问题,下面是客服端的代码。IP没有错

用http协议建立接连问题,下面是客服端的代码。IP没有错

慕村5072873 2018-02-05 17:39:58
public void printerInfo() {    System.out.println("爱的发发达发达的说");  URL url = null;    String uslStr = "http://192.168.0.106:8080/manage/typer/save.shtml";    try {        url = new URL(uslStr);        try {            PrecisionPrint precisionPrint = new PrecisionPrint();            JSONObject jsonObject = precisionPrint.getPrintMSg();            URLConnection urlConnection = url.openConnection();            urlConnection.setRequestProperty("content-type", "application/x-www-form-urlencoded");            urlConnection.setDoOutput(true);            urlConnection.setDoInput(true);            OutputStream out = urlConnection.getOutputStream();            out.write(jsonObject.toString().getBytes("utf-8"));            out.flush();            out.close();            // 从服务器读取响应           // InputStream inputStream = urlConnection.getInputStream();            //String body = IOUtils.toString(inputStream, "utf-8");            //System.out.println("返回的值是:" + body);        } catch (Exception e) {            e.printStackTrace();        }    } catch (MalformedURLException e) {        e.printStackTrace();    }}
查看完整描述

目前暂无任何回答

  • 0 回答
  • 0 关注
  • 915 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信