BVB Source Codes

spring-mvc-showcase Show ResponseController.java Source code

Return Download spring-mvc-showcase: download ResponseController.java Source code - Download spring-mvc-showcase Source code - Type:.java
  1. package org.springframework.samples.mvc.response;
  2.  
  3. import org.springframework.http.HttpHeaders;
  4. import org.springframework.http.HttpStatus;
  5. import org.springframework.http.MediaType;
  6. import org.springframework.http.ResponseEntity;
  7. import org.springframework.stereotype.Controller;
  8. import org.springframework.web.bind.annotation.RequestMapping;
  9. import org.springframework.web.bind.annotation.RequestMethod;
  10. import org.springframework.web.bind.annotation.ResponseBody;
  11.  
  12. @Controller
  13. @RequestMapping(value="/response", method=RequestMethod.GET)
  14. public class ResponseController {
  15.  
  16.         @RequestMapping("/annotation")
  17.         public @ResponseBody String responseBody() {
  18.                 return "The String ResponseBody";
  19.         }
  20.  
  21.         @RequestMapping("/charset/accept")
  22.         public @ResponseBody String responseAcceptHeaderCharset() {
  23.                 return "\u3053\u3093\u306b\u3061\u306f\u4e16\u754c\uff01 (\"Hello world!\" in Japanese)";
  24.         }
  25.  
  26.         @RequestMapping(value="/charset/produce", produces="text/plain;charset=UTF-8")
  27.         public @ResponseBody String responseProducesConditionCharset() {
  28.                 return "\u3053\u3093\u306b\u3061\u306f\u4e16\u754c\uff01 (\"Hello world!\" in Japanese)";
  29.         }
  30.  
  31.         @RequestMapping("/entity/status")
  32.         public ResponseEntity<String> responseEntityStatusCode() {
  33.                 return new ResponseEntity<String>("The String ResponseBody with custom status code (403 Forbidden)",
  34.                                 HttpStatus.FORBIDDEN);
  35.         }
  36.  
  37.         @RequestMapping("/entity/headers")
  38.         public ResponseEntity<String> responseEntityCustomHeaders() {
  39.                 HttpHeaders headers = new HttpHeaders();
  40.                 headers.setContentType(MediaType.TEXT_PLAIN);
  41.                 return new ResponseEntity<String>("The String ResponseBody with custom header Content-Type=text/plain",
  42.                                 headers, HttpStatus.OK);
  43.         }
  44.  
  45. }
  46.  
downloadResponseController.java Source code - Download spring-mvc-showcase Source code
Related Source Codes/Software:
tushare - TuShare is a utility for crawling historical data ... 2017-01-12
raml-spec - RAML Specification http://raml.... 2017-01-12
android-stackblur - Android StackBlur is a library that can perform a ... 2017-01-12
sound-redux - A Soundcloud client built with React / Redux ... 2017-01-12
httpstat - curl statistics made simple 2017-01-12
discover-flask - Full Stack Web Development with Flask. ... 2017-01-12
micro - Async HTTP microservices made easy ... 2017-01-12
gobot - Golang framework for robotics, drones, and the Int... 2017-01-11
mas - 2017-01-13
Zappa - Serverless Python Web Services ... 2017-01-12
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top