servlet生成保存图片,压缩zip见附件

用Retrofit模拟http请求 发起servlet,HttpClient也可以模拟http,form也可以模拟---post形式,ajax中的data对应request的body,流放在binary中,header放在header中。
<servlet> 
        <servlet-name>PictureCheckCode</servlet-name> 
        <servlet-class>com.wondersgroup.employeeBenefits.core.bases.util.PictureCheckCode</servlet-class> 
    </servlet> 
 
    <servlet-mapping> 
        <servlet-name>PictureCheckCode</servlet-name> 
        <url-pattern>/PictureCheckCode.jpeg</url-pattern> 
    </servlet-mapping> 



public void createSeq(String userId,String seq) {
// TODO Auto-generated method stub
try{
String url ="http://127.0.0.1:8080/employeeBenefits-main";
// String url ="http://127.0.0.1/employeeBenefits";WebConfig.get("sequrl"
InssureSeqClient service = RetrofitInssureSeqUtil.getService(InssureSeqClient.class,url);
service.getSeqPic(userId+"", seq);
}catch(Exception e){}
}




//String url = "http://172.16.21.21:8090/tpaService/rest/pic/uploadFiles?applyId="
// + caseCommitBean.getApplyId()
// + "&imageType="
// + caseCommitBean.getClaimType() + "";
// HttpClient client = new DefaultHttpClient();// 开启一个客户端 HTTP 请求
// HttpPost post = new HttpPost(url);// 创建 HTTP POST 请求
// post.addHeader("userId",userId);
// MultipartEntityBuilder builder = MultipartEntityBuilder.create();
// builder.setCharset(Charset.forName("UTF-8"));// 设置请求的编码格式
// builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);// 设置浏览器兼容模式
// int count = 0;
// String strZipName =WebConfig.get("filePath")+"/inssurePic/"+caseCommitBean.getApplyId()+ ".zip";
// File file1 = new File(strZipName);
//// File file2 = new File("E:\\files\\a.jpg");
// builder.addBinaryBody("files", file1);
// count++;
//// builder.addBinaryBody("files", file2);
// HttpEntity entity = builder.build();// 生成 HTTP POST 实体
// post.setEntity(entity);// 设置请求参数
// try {
// HttpResponse response = client.execute(post);// 发起请求 并返回请求的响应
// entity = response.getEntity();
// if (entity != null) {
// System.out.println("--------------------------------------");
// System.out.println("Response content: "
// + EntityUtils.toString(entity, "UTF-8"));
// System.out.println("--------------------------------------");
// }

你可能感兴趣的:(servlet生成保存图片,压缩zip见附件)