Complete the code to map a GET request to the path "/hello".
@RestController public class HelloController { @RequestMapping(value = "/hello", method = RequestMethod.[1]) public String sayHello() { return "Hello!"; } }
The @RequestMapping annotation uses method = RequestMethod.GET to handle GET requests.
Complete the code to map a POST request to the path "/submit".
@RestController public class SubmitController { @RequestMapping(value = "/submit", method = RequestMethod.[1]) public String submitData() { return "Submitted!"; } }
The POST method is used to submit data to the server.
Fix the error in the code to correctly map a DELETE request to "/remove".
@RestController public class RemoveController { @RequestMapping(value = "/remove", method = RequestMethod.[1]) public String removeItem() { return "Removed!"; } }
DELETE method is used to remove resources at the specified path.
Fill both blanks to map a PUT request to "/update" and specify the method correctly.
@RestController public class UpdateController { @RequestMapping(value = [1], method = RequestMethod.[2]) public String updateItem() { return "Updated!"; } }
The path should be "/update" and the method PUT for updating resources.
Fill all three blanks to map a PATCH request to "/modify", specify the method, and return a response.
@RestController public class ModifyController { @RequestMapping(value = [1], method = RequestMethod.[2]) public String modifyItem() { return [3]; } }
The path is "/modify", the method is PATCH, and the return string is "Modified!".
