0
I have a Rest service with the following method:
@RequestMapping(value = "/usuario/{login}", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity<InputStreamResource> usuario(@PathVariable("login") String login, HttpServletRequest request) {
User user = userService.buscarPorNickname(login);
InputStream is = null;
if (user != null) {
try {
is = new FileInputStream(user.getPicture().getCaminho());
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (is == null) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
} else {
return ResponseEntity.ok().contentType(MediaType.IMAGE_PNG).body(new InputStreamResource(is));
}
}
When the username has a point, the server understands it as a regular expression and returns me an empty file. How to get around this?
In the case of the query method that does not return the user? If yes, post the code of this method
– Marquezani