BVB Source Codes

spring-mvc-showcase Show MappingController.java Source code

Return Download spring-mvc-showcase: download MappingController.java Source code - Download spring-mvc-showcase Source code - Type:.java
  1. package org.springframework.samples.mvc.mapping;
  2.  
  3. import javax.servlet.http.HttpServletRequest;
  4.  
  5. import org.springframework.http.MediaType;
  6. import org.springframework.stereotype.Controller;
  7. import org.springframework.web.bind.annotation.RequestBody;
  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. public class MappingController {
  14.  
  15.         @RequestMapping("/mapping/path")
  16.         public @ResponseBody String byPath() {
  17.                 return "Mapped by path!";
  18.         }
  19.  
  20.         @RequestMapping(value="/mapping/path/*", method=RequestMethod.GET)
  21.         public @ResponseBody String byPathPattern(HttpServletRequest request) {
  22.                 return "Mapped by path pattern ('" + request.getRequestURI() + "')";
  23.         }
  24.  
  25.         @RequestMapping(value="/mapping/method", method=RequestMethod.GET)
  26.         public @ResponseBody String byMethod() {
  27.                 return "Mapped by path + method";
  28.         }
  29.  
  30.         @RequestMapping(value="/mapping/parameter", method=RequestMethod.GET, params="foo")
  31.         public @ResponseBody String byParameter() {
  32.                 return "Mapped by path + method + presence of query parameter!";
  33.         }
  34.  
  35.         @RequestMapping(value="/mapping/parameter", method=RequestMethod.GET, params="!foo")
  36.         public @ResponseBody String byParameterNegation() {
  37.                 return "Mapped by path + method + not presence of query parameter!";
  38.         }
  39.  
  40.         @RequestMapping(value="/mapping/header", method=RequestMethod.GET, headers="FooHeader=foo")
  41.         public @ResponseBody String byHeader() {
  42.                 return "Mapped by path + method + presence of header!";
  43.         }
  44.  
  45.         @RequestMapping(value="/mapping/header", method=RequestMethod.GET, headers="!FooHeader")
  46.         public @ResponseBody String byHeaderNegation() {
  47.                 return "Mapped by path + method + absence of header!";
  48.         }
  49.  
  50.         @RequestMapping(value="/mapping/consumes", method=RequestMethod.POST, consumes=MediaType.APPLICATION_JSON_VALUE)
  51.         public @ResponseBody String byConsumes(@RequestBody JavaBean javaBean) {
  52.                 return "Mapped by path + method + consumable media type (javaBean '" + javaBean + "')";
  53.         }
  54.  
  55.         @RequestMapping(value="/mapping/produces", method=RequestMethod.GET, produces=MediaType.APPLICATION_JSON_VALUE)
  56.         public @ResponseBody JavaBean byProducesJson() {
  57.                 return new JavaBean();
  58.         }
  59.  
  60.         @RequestMapping(value="/mapping/produces", method=RequestMethod.GET, produces=MediaType.APPLICATION_XML_VALUE)
  61.         public @ResponseBody JavaBean byProducesXml() {
  62.                 return new JavaBean();
  63.         }
  64.  
  65. }
  66.  
downloadMappingController.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