0

I need to pass many request params to @Controller.

So I want all these params to be wrapped into object which is provided as argument of @Controller by spring mvc. I also want to use @Valid annotation on this argument.

This is the same as @RequestBody with POST http method.

But I need object like @RequestBody with GET http method.

How to put all request params into single object which is provided as argument in @Controller method?

1 Answer 1

1

You can use @RequestBody as well, but you also have @ModelAttribute annotation to map parameters into a bean's properties.

Sign up to request clarification or add additional context in comments.

2 Comments

Can I use @RequestBody with RequestMethod.GET ?
You can, provided the parameters are whithin the request. You can use @ModelAttribute to map those parameters in the URL into a bean's properties as well (this is what I usually do). mkyong.com/spring-mvc/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.