mdsh.com/wiki


RecentChanges

TextFormattingRules
AllWikiTopics
OrphanedWikiTopics
ToDoWikiTopics
WikiLockList
RSS
Export2HTML

WikiSearch

SetUsername

StartingPoints
Home

Back to Spring MVC annotation.

Diff Spring MVC annotation

Line 0:
  +!!@RequestMapping!!
  +  
  +With ''params'' defined the request will only get passed to this method if the query parameters of the caller's URL exist. If no method matches the caller gets a 400.
  +[<java>]
  + @RequestMapping(value="/remote", params={"host"})
  + public ResponseEntity<?> remote(
  + @RequestParam(value = "host") final String host)
  + {
  + ...
  + }
  +[</java>]
  +  
  +Without ''params'' defined the request will also only get passed to this method if the query parameters of the callers URL exist. If not method matches the caller gets a 400 with a message saying the parameter is required
  +[<java>]
  + @RequestMapping(value="/remote")
  + public ResponseEntity<?> remote(
  + @RequestParam(value = "host") final String host)
  + {
  + ...
  + }
  +[</java>]
  +  
  +Without ''params'' defined and with the the @RequestParam defined to be not required this method will be called no matter whether the query parameter exists on the callers URL. It is up to the code to decide how to cope with the situation.
  +[<java>]
  + @RequestMapping(value="/remote")
  + public ResponseEntity<?> remote(
  + @RequestParam(value = "host", required = false) final String host)
  + {
  + if (null == host)
  + return new ResponseEntity<>("'host' parameter is required", HttpStatus.BAD_REQUEST);
  + ...
  + }
  +[</java>]


VeryQuickWiki Version 2.8.1 | Admin

All contents copyright mdsh.com (C) 2011-2023.