【发布时间】:2018-06-27 12:46:16
【问题描述】:
这是我的 java spring boot 代码。下面的代码是获取图像的其余函数。使用http get方法如何调用该方法并在角度4上显示图像?
@RequestMapping(value = "/get-file",method = RequestMethod.GET)
public void getImage(HttpServletResponse response) throws IOException
{
Long a = new Long(6);
ImageModel imageModel= imageRepository.getOne(a) ;
InputStream in = new ByteArrayInputStream(imageModel.getPic());
response.setContentType(MediaType.IMAGE_JPEG_VALUE);
IOUtils.copy(in, response.getOutputStream());
//System.out.println("get image ");
}
这是我的角码
public getCountry()
{
console.log("hey");
let url = 'http://localhost:8080/get-file';
return this._http.get(url,{ responseType: ResponseContentType.Blob }).map((res)=>res.blob());
}
【问题讨论】:
-
到目前为止,您在 Angular 中尝试了什么?
标签: angular spring-boot angular-http angular4-forms