@RequestMapping(value = "/something", method = RequestMethod.PATCH) @ResponseBody public String handlePartialUpdate(@RequestBody String content) throws IOException { return content; } }
@RequestMapping(value = "/{id}/foo") HttpEntity<Void> methodForNextPage(@PathVariable String id, @RequestParam Integer offset, @RequestParam Integer limit) { return null; }
@Override @RequestMapping(value = "/path1/path2", method = RequestMethod.POST) // NOTE: @ModelAttribute will NOT be found on the abstract superclass if // @RequestMapping is declared locally. Thus, we have to redeclare // @ModelAttribute locally as well. @ModelAttribute("attr2") public Date handle(@RequestHeader("header2") Date date, Model model) throws Exception { return date; }
@RestController @RequestMapping("/user") static class UserController { @GetMapping("/{id}") public Principal getUser() { return mock(Principal.class); } }
@RequestMapping("/notImplemented") @ResponseStatus(NOT_IMPLEMENTED) public @ResponseBody void notImplemented(){ } }
@RequestMapping("/{country}") HttpEntity<Void> getAddressesForCountry(@PathVariable String country) { return null; } }
@RequestMapping("/myPath.do") public void myHandle(@RequestParam(value = "id", required = true) int id, @RequestHeader(value = "header", required = true) String header) { } }
@RequestMapping(value="/blog.atom", method = { GET, HEAD }) @ResponseBody public String listPublishedPosts() { return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" + "<feed xmlns=\"http://www.w3.org/2005/Atom\">\r\n" + " <title>Test Feed</title>\r\n" + " <icon>http://www.example.com/favicon.ico</icon>\r\n" + "</feed>\r\n\r\n"; } }
@RequestMapping(value = "/path1/path2", method = RequestMethod.POST) @ModelAttribute("attr2") public Date handle(C date, Model model) throws Exception { return (Date) date; }
@CrossOrigin(origins = { "http://site1.com", "http://site2.com" }, allowedHeaders = { "header1", "header2" }, exposedHeaders = { "header3", "header4" }, methods = RequestMethod.DELETE, maxAge = 123, allowCredentials = "false") @RequestMapping(path = "/customized", method = { RequestMethod.GET, RequestMethod.POST }) public void customized() { }
@CrossOrigin @GetMapping(path = "/ambiguous-produces", produces = "application/xml") public String ambiguousProducesXml() { return "<a></a>"; }
@RequestMapping(value = "/something", method = RequestMethod.PUT) @ResponseBody public String handle(@RequestBody String body) throws IOException { return body; }
@RequestMapping(value = "/{id}/foo") HttpEntity<Void> methodWithMultiValueRequestParams(@PathVariable String id, @RequestParam List<Integer> items, @RequestParam Integer limit) { return null; }
@Override @RequestMapping(value="/path1/path2", method=RequestMethod.POST) @ModelAttribute("attr2") public Date handle(@RequestHeader("header2") Date date, Model model) throws Exception { return date; }
@RequestMapping(value="/handleUtf8", produces="text/plain;charset=UTF-8") @ResponseBody public String handleWithCharset() { return "\u3053\u3093\u306b\u3061\u306f\u4e16\u754c\uff01"; // "Hello world! (Japanese) } }
@Override @RequestMapping(method = RequestMethod.POST) public String post(@ModelAttribute("object1") TestBean object1) { //do something with object1 return "page2"; } }
@CrossOrigin(allowCredentials = "bogus") @RequestMapping("/bogus") public void bogusAllowCredentialsValue() { } }
@RequestMapping(value = "/something", method = RequestMethod.PUT, produces = "text/plain") @ResponseBody public String handle(@RequestBody String body) throws IOException { return body; } }
@RequestMapping(value="/path1/path2", method=RequestMethod.POST) @ModelAttribute("attr2") public Date handle(@RequestHeader("header2") Date date) throws Exception { return date; }
@RequestMapping(value="/path2", method=RequestMethod.POST) @ModelAttribute("attr2") public Date handle(@RequestHeader("header2") Date date, Model model) throws Exception { return date; }