public String doUploadFile(GaStAuthParam auth, WriteI02C77Bean vio) throws Exception {…
Jump to turn (6)
- User
public String doUploadFile(GaStAuthParam auth, WriteI02C77Bean vio) throws Exception { String urlstr = String.format( "http://10.72.37.126:9080/trffweb/uploadFile.frm?method=savePicture&jkxlh=%s&sfzmhm=%s&jkid=%s&xtlb=%s", auth.getAuthWebServices().get(0).getBaseFace().getJkxlh(), vio.getSfzmhm(), auth.getJkid(), getXtlb()); log.info("urlstr:"+urlstr); URL url = new URL(urlstr); HttpURLConnection huc = (HttpURLConnection) url.openConnection(); huc.setRequestProperty("content-type", "text/html"); huc.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); huc.setDoOutput(true); huc.setDoInput(true); huc.setRequestMethod("POST"); huc.setConnectTimeout(500000); OutputStream pw = huc.getOutputStream(); byte[] fileData = new BASE64Decoder().decodeBuffer(vio.getZp()); pw.write(fileData); pw.flush(); pw.close(); BufferedReader br = new BufferedReader(new InputStreamReader(huc.getInputStream())); StringBuilder content = new StringBuilder(); String line; while ((line = br.readLine()) != null) { content.append(line); // 使用 StringBuilder进行拼接 } } br.close(); String response = content.toString(); return response; } import sun.misc.BASE64Decoder; 请求 BufferedReader br = new BufferedReader(new InputStreamReader(huc.getInputStream())); 报错 500 你能帮我分析下原因吗