-
Mar 3rd, 2011, 11:58 PM
#1
Passing bean reference to the view
Hello!
I'm new to Spring and this might be the wrong way to do it, but here it goes. I have a bean, newUser, that I added to the myModel hashMap, which will be passed to the view like this:
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
NewUserIntro newUser = new NewUserIntro();
newUser.setInfo("", "", "","");
String now1 = (new Date()).toString();
Map<String, Object> myModel = new HashMap<String, Object>();
myModel.put("test", newUser);
myModel.put("test", now1);
return new ModelAndView("newuser", "model", myModel);
}
I want to be able to post via the bean from the view, as well as fetch other data from the hashmap that is getting passed. Here is the top part of the jsp post
<form:form method="post" commandName=????????>
<table width="55%" bgcolor="f8f8f9" border="4" cellspacing="0" cellpadding="10">
<tr>
<td align="left" width="20%">Name: </td>
<td width="25%">
<form:input path="name"/>
..
..
..
How do I reference the bean from the hashmap in the commandName? Also, the bean is not initilized anywhere else but that shouldn't be an issue.
If anybody has any questions let me know please, and I realize that it might not be possible to do it this way.
Thanks!!!
Last edited by rufu; Mar 4th, 2011 at 12:01 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules