Generate a scenario based coding snippet question having multiple choice options on…
- User
Generate a scenario based coding snippet question having multiple choice options on Spring Boot Filtration. Share the correct answer with reason for the same
Assistant
Here is a scenario based coding snippet question on Spring Boot Filtration with multiple choice options and correct answer with reason:
Scenario: You have a Spring Boot application with some REST API endpoints. You want to add a filter to log the request details for all the requests. Which of the following options will you use?
Options:
A. @WebFilter annotation on a class B. Implement Filter interface C. Extend OncePerRequestFilter class D. Use @Filter annotation on a method
Correct answer: B. Implement Filter interface
Reason: To add a filter in Spring Boot, you need to implement the Filter interface. The methods that need to be implemented are:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.