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
YouTubeCenter - YouTube Center is a userscript designed to expand ... 2017-01-14
node-osmosis - Web scraper for NodeJS 2017-01-13
liquidfun - 2D physics engine for games htt... 2017-01-13
locutus - All your standard libraries will be assimilated in... 2017-01-13
VBFPopFlatButton - Flat button with 9 different states using POP 2017-01-13
hubpress.io - A web application to build your blog on GitHu 2017-01-13
sunspot - Solr-powered search for Ruby objects ... 2017-01-13
thrust - Chromium-based cross-platform / cross-language app... 2017-01-13
rubinius - The Rubinius Language Platform ... 2017-01-13
rework - Plugin framework for CSS preprocessing in Node.j 2017-01-13

 Back to top