Close
« Tutorial

Spring MVC - DefaultHandlerExceptionResolver MCQ

0/13
0 ✓
0 ✗

1. What is the main job of DefaultHandlerExceptionResolver?

2. Do you need to register DefaultHandlerExceptionResolver manually in the DispatcherServlet?

3. Which method does DefaultHandlerExceptionResolver use to send the status code to the client?

4. What does the client usually see when this resolver handles an exception?

5. Why are HTTP status codes especially important for automated clients?

6. A client sends a POST request with Content-Type: text/plain to the handler below. What status code is returned?

@RequestMapping(
    value = "/save",
    method = RequestMethod.POST,
    consumes = "application/json")
@ResponseBody
public String save(@RequestBody String body) {
    return "body: " + body;
}

7. A client sends a GET request to the handler below. What status code is returned?

@RequestMapping(
    value = "/save",
    method = RequestMethod.POST)
@ResponseBody
public String save(@RequestBody String body) {
    return "body: " + body;
}

8. Which exception does Spring MVC throw for the handler below when it is called?

@RequestMapping("/item/{id}")
@ResponseBody
public String item(
        @PathVariable("itemId") int id) {
    return "id: " + id;
}

9. What HTTP status code does MissingPathVariableException produce?

10. Which exception causes a 405 status code?

11. Which exception causes a 415 status code?

12. Which handler attribute makes Spring MVC reject requests with a non-matching Content-Type header?

Join