BVB Source Codes

spring-mvc-showcase Show RequestDataController.java Source code

Return Download spring-mvc-showcase: download RequestDataController.java Source code - Download spring-mvc-showcase Source code - Type:.java
  1. package org.springframework.samples.mvc.data;
  2.  
  3. import org.springframework.http.HttpEntity;
  4. import org.springframework.stereotype.Controller;
  5. import org.springframework.web.bind.annotation.CookieValue;
  6. import org.springframework.web.bind.annotation.MatrixVariable;
  7. import org.springframework.web.bind.annotation.PathVariable;
  8. import org.springframework.web.bind.annotation.RequestBody;
  9. import org.springframework.web.bind.annotation.RequestHeader;
  10. import org.springframework.web.bind.annotation.RequestMapping;
  11. import org.springframework.web.bind.annotation.RequestMethod;
  12. import org.springframework.web.bind.annotation.RequestParam;
  13. import org.springframework.web.bind.annotation.ResponseBody;
  14.  
  15. @Controller
  16. @RequestMapping("/data")
  17. public class RequestDataController {
  18.  
  19.         @RequestMapping(value="param", method=RequestMethod.GET)
  20.         public @ResponseBody String withParam(@RequestParam String foo) {
  21.                 return "Obtained 'foo' query parameter value '" + foo + "'";
  22.         }
  23.  
  24.         @RequestMapping(value="group", method=RequestMethod.GET)
  25.         public @ResponseBody String withParamGroup(JavaBean bean) {
  26.                 return "Obtained parameter group " + bean;
  27.         }
  28.  
  29.         @RequestMapping(value="path/{var}", method=RequestMethod.GET)
  30.         public @ResponseBody String withPathVariable(@PathVariable String var) {
  31.                 return "Obtained 'var' path variable value '" + var + "'";
  32.         }
  33.  
  34.         @RequestMapping(value="{path}/simple", method=RequestMethod.GET)
  35.         public @ResponseBody String withMatrixVariable(@PathVariable String path, @MatrixVariable String foo) {
  36.                 return "Obtained matrix variable 'foo=" + foo + "' from path segment '" + path + "'";
  37.         }
  38.  
  39.         @RequestMapping(value="{path1}/{path2}", method=RequestMethod.GET)
  40.         public @ResponseBody String withMatrixVariablesMultiple (
  41.                         @PathVariable String path1, @MatrixVariable(value="foo", pathVar="path1") String foo1,
  42.                         @PathVariable String path2, @MatrixVariable(value="foo", pathVar="path2") String foo2) {
  43.  
  44.                 return "Obtained matrix variable foo=" + foo1 + " from path segment '" + path1
  45.                                 + "' and variable 'foo=" + foo2 + " from path segment '" + path2 + "'";
  46.         }
  47.  
  48.         @RequestMapping(value="header", method=RequestMethod.GET)
  49.         public @ResponseBody String withHeader(@RequestHeader String Accept) {
  50.                 return "Obtained 'Accept' header '" + Accept + "'";
  51.         }
  52.  
  53.         @RequestMapping(value="cookie", method=RequestMethod.GET)
  54.         public @ResponseBody String withCookie(@CookieValue String openid_provider) {
  55.                 return "Obtained 'openid_provider' cookie '" + openid_provider + "'";
  56.         }
  57.  
  58.         @RequestMapping(value="body", method=RequestMethod.POST)
  59.         public @ResponseBody String withBody(@RequestBody String body) {
  60.                 return "Posted request body '" + body + "'";
  61.         }
  62.  
  63.         @RequestMapping(value="entity", method=RequestMethod.POST)
  64.         public @ResponseBody String withEntity(HttpEntity<String> entity) {
  65.                 return "Posted request body '" + entity.getBody() + "'; headers = " + entity.getHeaders();
  66.         }
  67.  
  68. }
  69.  
downloadRequestDataController.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