Home > front end >  Axios request, access to the back-end picture file streams, Chinese garbled problems need to solve,
Axios request, access to the back-end picture file streams, Chinese garbled problems need to solve,

Time:05-05

Java code:
@ RequestMapping ("/showDiagram ")
//show the flow chart of
Public String showDiagram (HttpServletResponse response) {
OutputStream out=null;
String processInstanceId="5001";
Try {
//HttpServletResponse response=ServletActionContext. The method getResponse ();
InputStream is=this. GetDiagram (processInstanceId);
The response. SetContentType (" image/PNG; Charset=utf8 ");
Out=response. GetOutputStream ();
Out. Write (getImgByte (is));
Out. The flush ();
} the catch (Exception e) {
e.printStackTrace();
} the finally {
Try {
Out. The close ();
} the catch (Exception e) {
}
}
return null;
}

Vue code:

Greet () {
Var url='/sde/showDiagram/';
This $axios. Post (url, {
ResponseType: 'arraybuffer',
//headers: {' the content-type ':' multipart/form - data; Charset=utf-8 '},
}). Then (res=& gt; {


The console. The log (res. Data);
//the document. The getElementById (" imgTest "). The SRC=https://bbs.csdn.net/topics/res.data;

})
}

CodePudding user response:

This problem solved
  • Related