I have a Spring endpoint for my REST web services application that I want to return a string:
"Unauthorized: token is invalid"
But my front-end javascript throttles on this:
JSON.parse("Unauthorized: token is invalid")
How do I get my application to return a valid JSON string? Here is my current code:
@RequestMapping(value="/401") public ResponseEntity<String> unauthorized() { return new ResponseEntity<String>("Unauthorized: token is invalid", HttpStatus.UNAUTHORIZED); }
java json spring spring-mvc
user1007895
source share