[BAEL-3279]Add missing code snippets from the Spring RequestMapping article (#7768)

* [BAEL-3279]Add missing code snippets from the Spring RequestMapping article

* [BAEL-3279] Updated snippets

* changhed tabs to spaces

* fixed import issues

* fixed package
This commit is contained in:
NickTononi 2019-09-11 13:23:33 +02:00 committed by Josh Cummings
parent ff15a61559
commit b7c58ddce6

View File

@ -1,6 +1,8 @@
package com.baeldung.requestmapping;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@ -97,5 +99,29 @@ public class FooMappingExamplesController {
public String putAndPostFoos() {
return "Advanced - PUT and POST within single method";
}
// --- Ambiguous Mapping
@GetMapping(value = "foos/duplicate" )
public String duplicate() {
return "Duplicate";
}
// uncomment for exception of type java.lang.IllegalStateException: Ambiguous mapping
}
// @GetMapping(value = "foos/duplicate" )
// public String duplicateEx() {
// return "Duplicate";
// }
@GetMapping(value = "foos/duplicate/xml", produces = MediaType.APPLICATION_XML_VALUE)
public String duplicateXml() {
return "Duplicate Xml";
}
@GetMapping(value = "foos/duplicate/json", produces = MediaType.APPLICATION_JSON_VALUE)
public String duplicateJson() {
return "Duplicate Json";
}
}