How to whitelist/blacklist parameters in @RequestBody

prranay :

I want to allow only isActive and name parameter in the @RequestBody and want to ignore price attribute.

Is there a way to do so in Spring Boot?

{
    "isActive": true,
    "name": "prandajsbdduts",
    "price": 10
}
Andronicus :

Sure, you just don't need to put price field in your DTO. When you have something like this:

public class SomeDTO {
    private Boolean isActive;
    private String name;
    /getters & setters
}

price will be ignored.

Collected from the Internet

Please contact javaer1[email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to pass multiple parameters to @RequestBody using JavaScript XMLHttpRequest

How to get parameters from RequestBody in Spring REST controller method

RequestBody and camel case request parameters

@JsonView how to use with @RequestBody

springboot, how to valid @RequestBody

Spring Boot @RequestBody does not copy parameters fully

Spring REST multiple @RequestBody parameters, possible?

How to pass 2 objects in @RequestBody?

How to limit fields that map in @RequestBody

How to use @RequestBody and @RequestParam together

Can spring map POST parameters by a way other than @RequestBody

How to replace deprecated okhttp.RequestBody.create()

How to pass @RequestBody parameter of controller using MockMVC

How to custom convert String to enum in @RequestBody?

How to pass @RequestBody list of object in XML

How to send @Requestbody and @Requestpart together in spring

How to get the @RequestBody in an @ExceptionHandler (Spring REST) 2.0

How to automatically parse String @RequestBody as json

How to use @RequestBody in Spring Webflux and avoid IllegalStateException?

how to receive a json object with @RequestBody or @RequestParam

How do I combine @PathParams and @RequestBody properly?

How to bind JSON hasmasp to the @RequestBody in spring boot

How to get the @RequestBody in an @ExceptionHandler (Spring REST)

How to send a custom validation Json object for the requestbody?

How to accept RequestBody of different class types dynamically

Loopback 4 How to validate requestBody properties

How to pass body @RequestBody and @RequestParam in same request

How to exclude fields from RequestBody - Swagger

How to Pass two @RequestBody objects in one method