Spring MVC - HttpEntity Examples

Spring MVC 

Demonstrating support for HTTP Head verb, no method with HEAD defined. Get will handle the request.

public class MyController {
Logger logger = Logger.getLogger(MyController.class.getSimpleName());

@RequestMapping(value = "test", method = {RequestMethod.GET})
public HttpEntity<String> handleTestRequest () {

MultiValueMap<String, String> headers = new HttpHeaders();
headers.put("test-header", Arrays.asList("test-header-value"));

HttpEntity<String> responseEntity = new HttpEntity<>("test body", headers);"handler finished");
return responseEntity;
Original Post

See Also