@ResponseBody和ResponseEntity

@RequestMapping(value="/response", method=RequestMethod.GET)
public class ResponseController {

//http://127.0.0.1:8010/response/annotation
	@RequestMapping("/annotation")
	public @ResponseBody String responseBody() {
		return "The String ResponseBody";
	}


	@RequestMapping("/charset/accept")
	public @ResponseBody String responseAcceptHeaderCharset() {
		return "\u3053\u3093\u306b\u3061\u306f\u4e16\u754c\uff01 (\"Hello world!\" in Japanese)";
	}

//http://127.0.0.1:8010/response/charset/produce
	@RequestMapping(value="/charset/produce", produces="text/plain;charset=UTF-8")
	public @ResponseBody String responseProducesConditionCharset() {
		return "\u3053\u3093\u306b\u3061\u306f\u4e16\u754c\uff01 (\"Hello world!\" in Japanese)";
	}

//http://127.0.0.1:8010/response/entity/status
	@RequestMapping("/entity/status")
	public ResponseEntity responseEntityStatusCode() {
		return new ResponseEntity("The String ResponseBody with custom status code (403 Forbidden)",
				HttpStatus.FORBIDDEN);
	}

//http://127.0.0.1:8010/response/entity/headers
	@RequestMapping("/entity/headers")
	public ResponseEntity responseEntityCustomHeaders() {
		HttpHeaders headers = new HttpHeaders();
		headers.setContentType(MediaType.TEXT_PLAIN);
		return new ResponseEntity("The String ResponseBody with custom header Content-Type=text/plain",
				headers, HttpStatus.OK);
	}

}