Discussion:
Passing Request Parameters between Controllers in Spring MVC
Ernesto Echeverría
2005-08-28 21:13:20 UTC
Permalink
sorry if duplicate I was using a different account



Question: (trying to find my way with Spring MVC and JSPs in general, this
is a newbie kind of question)

When passing parameter requests to a controller (as request parameters in
the URL), is there a way for passing those same parameters in

For a practical example, let's say we have the UserController (related to
the users.html page). If that page is invoked, say as,

http://localhost:8080/appfuse/users.html?param=value

The controller can then evaluate this parameter and take proper action,
however, what's the proper way to inject this parameter into the
ModelAndView that's returned?

I'd like to be able to use that parameter in the next url (in the
userList.jsp) to look like "/editUser.html?form=list&param=value"

I've been able to inject reference values and extra values to the command
object using the referenceData method of BaseFormControllers, but don't have
anything equivalent for plain Controllers.

What are the options? or is there anything simpler than that?

TIA.
José Ernesto Echeverría
2005-08-28 21:04:58 UTC
Permalink
Question: (trying to find my way with Spring MVC and JSPs in general, this
is a newbie kind of question)

When passing parameter requests to a controller (as request parameters in
the URL), is there a way for passing those same parameters in

For a practical example, let's say we have the UserController (related to
the users.html page). If that page is invoked, say as,

http://localhost:8080/appfuse/users.html?param=value

The controller can then evaluate this parameter and take proper action,
however, what's the proper way to inject this parameter into the
ModelAndView that's returned?

I'd like to be able to use that parameter in the next url (in the
userList.jsp) to look like "/editUser.html?form=list&param=value"

I've been able to inject reference values and extra values to the command
object using the referenceData method of BaseFormControllers, but don't have
anything equivalent for plain Controllers.

What are the options? or is there anything simpler than that?

TIA.
Sanjiv Jivan
2005-08-29 15:25:28 UTC
Permalink
Use RedirectView as the view and add the request parameters in the model.

See
http://www.springframework.org/docs/api/org/springframework/web/servlet/view/RedirectView.html

As stated in the Javadocs, RedirectView is a "View that redirects to an
absolute, context relative, or current request relative URL, exposing all
model attributes as HTTP query parameters."

Map model = new HashMap();
model.put("form", "list");
model.put("param", "value");

from UserController return

new ModelAndView(new RedirectView("edit.html"), model);

Hope this helps.
Sanjiv
Post by Ernesto Echeverría
sorry if duplicate I was using a different account
Question: (trying to find my way with Spring MVC and JSPs in general,
this is a newbie kind of question)
When passing parameter requests to a controller (as request parameters in
the URL), is there a way for passing those same parameters in
For a practical example, let's say we have the UserController (related to
the users.html page). If that page is invoked, say as,
http://localhost:8080/appfuse/users.html?param=value
The controller can then evaluate this parameter and take proper action,
however, what's the proper way to inject this parameter into the
ModelAndView that's returned?
I'd like to be able to use that parameter in the next url (in the
userList.jsp) to look like "/editUser.html?form=list&param=value"
I've been able to inject reference values and extra values to the command
object using the referenceData method of BaseFormControllers, but don't have
anything equivalent for plain Controllers.
What are the options? or is there anything simpler than that?
TIA.
Ernesto Echeverría
2005-08-30 13:34:47 UTC
Permalink
Thanks for your answer. I'll try this approach and let you know.

_____

From: Sanjiv Jivan [mailto:sanjiv.jivan-***@public.gmane.org]
Sent: Lunes, 29 de Agosto de 2005 09:25 a.m.
To: users-***@public.gmane.org
Subject: [tech] Re: [appfuse-user] Passing Request Parameters between
Controllers in Spring MVC


Use RedirectView as the view and add the request parameters in the model.

See
http://www.springframework.org/docs/api/org/springframework/web/servlet/view
/RedirectView.html

As stated in the Javadocs, RedirectView is a "View that redirects to an
absolute, context relative, or current request relative URL, exposing all
model attributes as HTTP query parameters."

Map model = new HashMap();
model.put("form", "list");
model.put("param", "value");

from UserController return

new ModelAndView(new RedirectView("edit.html"), model);

Hope this helps.
Sanjiv


On 8/28/05, Ernesto Echeverría <ernestoe-***@public.gmane.org> wrote:

sorry if duplicate I was using a different account



Question: (trying to find my way with Spring MVC and JSPs in general, this
is a newbie kind of question)

When passing parameter requests to a controller (as request parameters in
the URL), is there a way for passing those same parameters in

For a practical example, let's say we have the UserController (related to
the users.html page). If that page is invoked, say as,

http://localhost:8080/appfuse/users.html?param=value
<http://localhost:8080/appfuse/users.html?param=value>

The controller can then evaluate this parameter and take proper action,
however, what's the proper way to inject this parameter into the
ModelAndView that's returned?

I'd like to be able to use that parameter in the next url (in the
userList.jsp) to look like "/editUser.html?form=list&param=value"

I've been able to inject reference values and extra values to the command
object using the referenceData method of BaseFormControllers, but don't have
anything equivalent for plain Controllers.

What are the options? or is there anything simpler than that?

TIA.

Loading...