Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing parameters in redirect view Spring MVC

Tags:

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?

like image 903
user746458 Avatar asked Jan 01 '13 15:01

user746458


1 Answers

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.

like image 183
JB Nizet Avatar answered Sep 30 '22 19:09

JB Nizet