I have Spring Rest controller,as below :
@RestController
@RequestMapping(value = "/v1/files")
public class DataReader {
@GetMapping(value = "/", produces = MediaType.TEXT_HTML_VALUE)
public Employee readData () {
Employee employee = new Employee();
employee.setName("GG");
employee.setAddress("address");
employee.setPostCode("postal code");
return employee;
}
}
Basically,I want this controller to return html content.However,when I hit the URI from the browser or from postman,I get following exception :
There was an unexpected error (type=Not Acceptable, status=406).
Could not find acceptable representation
org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation
at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:316)
at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.handleReturnValue(RequestResponseBodyMethodProcessor.java:181)