I have three resources:
@RequestMapping(value = "sample", method = RequestMethod.GET, headers = "Accept=text/html")
public ResponseEntity<String> sampleResourceHtml()
@RequestMapping(value = "sample", method = RequestMethod.GET, headers = "Accept=application/xml")
public ResponseEntity<String> sampleResourceXml()
@RequestMapping(value = "sample", method = RequestMethod.GET, headers = "Accept=application/json")
public ResponseEntity<String> sampleResourceJson()
When an HTTP client accesses a URL using Accept = * / *, webapp returns 404
In this case, I want to call sampleResourceHtml()
Changing "Accept=text/html"to "Accept=text/html, */*"will cause my webapp to accept requests with Accept = * / *, which I want, however it will also accept requests with Accept = foo / bar, which is not what I want.
How can I change my code to return a supported media type for queries that contain wildcards without returning an unexpected media type for unsupported queries?
source
share