这是我的代码。它似乎错误地改变了我的base64图像。
@RequestMapping(value = "/get/**", method = RequestMethod.GET)
public String home(Locale locale, Model model, HttpServletRequest request) {
String query = request.getRequestURI().replaceAll("/OtkProxy/get/", "");
final String uri = "http://110.25.114.11/"+query;
RestTemplate restTemplate = new RestTemplate();
String result = restTemplate.getForObject(uri, String.class);
model.addAttribute("data", result);
return "home";
}
我做错了什么?
答案 0 :(得分:1)
管理这样做:
@RequestMapping(value = "/getphoto/**", method = RequestMethod.GET)
public void homephoto(HttpServletResponse response, HttpServletRequest request) {
String query = request.getRequestURI().replaceAll("/OtkProxy/getphoto/", "");
//final String uri = "http://10.25.114.11/"+query;
final String uri = "http://qmatic.faceis.ru/"+query;
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.IMAGE_JPEG);
HttpEntity entity = new HttpEntity(headers);
String res = restTemplate.getForObject(uri, String.class, entity);
response.setContentType("image/jpeg");
try {
response.getOutputStream().print(res);
}
catch (Exception ex)
{
System.out.println("getphoto - " + ex.getMessage());
}
}