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
FrameworkBenchmarks - Source code for the framework benchmarking project... 2017-02-22
buildbot - Python-based continuous integration testing framew... 2017-02-22
rufus - The Reliable USB Formatting Utility ... 2017-02-22
uiGradients - Beautiful colour gradients for design and code ... 2017-02-22
Haxl - A Haskell library that simplifies access to remote... 2017-02-21
duktape - Duktape - embeddable Javascript engine with a focu... 2017-02-21
scala-best-practices - A collection of Scala best practice 2017-02-21
hammerspoon - Staggeringly powerful OS X desktop automation with... 2017-02-21
DGElasticPullToRefresh - Elastic pull to refresh for iOS developed in Swift 2017-02-21
evercookie - evercookie is a javascript API that produces extre... 2017-02-21

 Back to top