The servlet generates and saves the picture, and the compressed zip is shown in the attachment

Use Retrofit to simulate http request to initiate servlet, HttpClient can also simulate http, form can also simulate ---post form, the data in ajax corresponds to the body of the request, the stream is placed in the binary, and the header is placed in the 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"));// Set the encoding format of the request
// builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);// Set the browser compatibility mode
// 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();// Generate HTTP POST entity
// post.setEntity(entity);// Set request parameters
// try {
// HttpResponse response = client.execute(post);// Initiate request and Returns the request's response
// entity = response. getEntity();
// if (entity != null) {
// System.out.println("--------------------------------------");
// System.out.println("Response content: "
// + EntityUtils.toString(entity, "UTF-8"));
// System.out.println("--------------------------------------");
// }

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326817125&siteId=291194637