[BAEL-2248] Add Controller Method to accept form data
Add Test method in RestTemplateBasicLiveTest
This commit is contained in:
@@ -5,13 +5,9 @@ import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
|
||||
import org.baeldung.web.dto.Foo;
|
||||
import org.baeldung.web.dto.FooProtos;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Controller
|
||||
public class FooController {
|
||||
@@ -47,7 +43,7 @@ public class FooController {
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/foos/new")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
@ResponseBody
|
||||
public Foo createFoo(@RequestBody final Foo foo) {
|
||||
return foo;
|
||||
@@ -60,4 +56,11 @@ public class FooController {
|
||||
return id;
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/foos/form")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
@ResponseBody
|
||||
public String submitFoo(@RequestParam("id") String id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user