Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spring MVC - ModelAttribute with MultiActionController

 
Auton Flores
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody, I need some help with this issue: I would like to get an object from a jsp page on my MultiActionController's method.

I do have a list of object Pessoa on my jsp page, and for each one object I provide action's hyperlinks to the MultiActionController's method, just like the code below. So, when the user gets these links it should be forward to the respective method with its pessoa object fullfiled. But what I'm getting now is just a null pessoa object.

What am I missing to get this to work properly?

My Action (MultiActionController):


My jsp:


I would appreciate any directions.

Regards, newbcc
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you said MultiActionController I thought you were extending that class in the Spring Framework (which you should not be doing anymore since version 2.5) It seems you are using the controller correctly but I would get out of the habit of calling it a MultiActionController as it is a bit misleading

Anyway your model object will be null because because your not binding it. Use the Spring form tag to create a form and bind your model object to it. Also there is no need to pass in the request and response as it appears you are not using them. Also you can just return String instead of ModelAndView where String is the view name. The ModelAttribute you pass in as a parameter will automatically be included. You are not using the "msg"


Have a look at this for an example of the things you can do with the form tag.
https://github.com/SpringSource/spring-mvc-showcase/blob/master/src/main/webapp/WEB-INF/views/form.jsp
 
Auton Flores
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Bill,

First of all I would like to thank you for the reply.

But even if I would want to follow with this strategy is there any way for me to do it so? I mean, this example is a type of POC and I do not intend to keep writing codes using these controller. It is just for studying purpose.

By the way, the sample code I put in here it is not the original one, for this reason it is not showing the use of the pessoa and the msg objects.

Regards!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic