How can you specify a default value for a request parameter in a Spring Boot controller method?
- Creating a custom annotation.
- Default values for request parameters are not supported in Spring Boot.
- Setting the default value in the application.properties file.
- Using the @RequestParam annotation with the defaultValue attribute.
You can specify a default value for a request parameter in a Spring Boot controller method using the @RequestParam annotation with the defaultValue attribute. This attribute allows you to provide a default value that will be used if the parameter is not present in the request. Setting the default value in the application.properties file is not the correct approach, and creating a custom annotation is not a standard way to specify default values for request parameters.
Loading...
Related Quiz
- How would you optimize Request Mapping in a large Spring Boot application with numerous endpoints?
- The _____ annotation in Spring is used to give a preference to a bean when multiple beans of the same type exist.
- When performing integration testing in Spring Boot, which of the following is used to load only specific slices of the application?
- For creating a custom constraint annotation in Spring Boot, the annotation should be annotated with _____.
- The error messages of validation constraints in Spring Boot can be externalized using the _____ property in the constraint annotation.