2016-04-22 14 views
5

pisałem który powróci stan zdrowia po nazwieWiosna Reszta Zgłoszenie serwisowe powrocie błąd na linii 1 w kolumnie 1: Dokument jest pusty

@RestController 
@RequestMapping(value = "/account") 
public class HealthCheckController { 

    protected final Logger log = LoggerFactory.getLogger(this.getClass()); 

    @RequestMapping(value = "/health", method = RequestMethod.GET, produces = { "application/json" }) 
    @ResponseStatus(HttpStatus.OK) 
    @ApiOperation(value = "Returns the health status of the application", notes = "Load balancer user this to confirm the health of the node") 
    public @ResponseBody String getHealth(HttpServletRequest request, HttpServletResponse response) throws Exception { 

     log.info("***" + RequestCorrelation.getId() + "***" + "HealthCheckController - getHealth() Called"); 

     return "{\"health\":{\"SERVICES\":\"OK\"}}"; 
    } 

} 

Kiedy otwieram to w puszyć lub listonosza REST połączenia zwraca prawidłową odpowiedź . Ale kiedy trafiam ten adres URL w przeglądarce Chrome, widzę teraz:

This page contains the following errors: 

error on line 1 at column 1: Document is empty 
Below is a rendering of the page up to the first error. 

Dlaczego tak jest? i jak to naprawić?

Odpowiedz

0

Staraj się nie zwracać ciąg ale

return new ResponseEntity<>(yourString, HttpStatus.OK); 

a także zmienić

public @ResponseBody String getHealth(HttpServletRequest request, HttpServletResponse response) throws Exception { 

do tego

public @ResponseBody ResponseEntity<String> getHealth(HttpServletRequest request, HttpServletResponse response) throws Exception { 

A jeśli to nie działa, spróbuj dodać. xml lub .json na końcu adresu URL, gdy uzyskujesz do niego dostęp w przeglądarce.

Powiązane problemy