user746458
user746458

Reputation: 369

Passing parameters in redirect view Spring MVC

I am not able to get how to pass a parameter along with a main url from a controller. I tried like this:

           return new ModelAndView(new RedirectView("home?var=ss", true));

But I am getting null value for var . What is the correct way?

Upvotes: 5

Views: 15424

Answers (1)

JB Nizet
JB Nizet

Reputation: 692231

The documentation says:

By default all model attributes are considered to be exposed as URI template variables in the redirect URL. Of the remaining attributes those that are primitive types or collections/arrays of primitive types are automatically appended as query parameters.

So you don't have anything to do except making sure that you have a model attribute named var, with the value ss.

Upvotes: 16

Related Questions