Here is my JSP code:
<%@ page session="false"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
<title>Example Application</title>
</head>
<body topmargin="0" leftmargin="0">
<table align="center" cellpadding="50">
<tr>
<td>
<form method="post">
<table align="center" cellspacing="1" cellpadding="0">
<tr>
<th align="center">Person</th>
</tr>
<tr>
<td>
<table width="100%" cellpadding="5">
<tr>
<td align="right"><b></b>First Name:</td>
<td>
<spring:bind path="command.firstName">
<input type="text" name="<c:out value="${status.expression}"/>" value="<c:out value="${status.value}"/>" maxlength="50" size="50" />
</spring:bind>
</td>
</tr>
<tr>
<td align="right"><b></b>Last Name:</td>
<td>
<spring:bind path="command.lastName">
<input type="text" name="<c:out value="${status.expression}"/>" value="<c:out value="${status.value}"/>" maxlength="50" size="50" />
</spring:bind>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<input type="submit" value="Save" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>
Here is my Controller code:
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response,
Object command, BindException errors) throws Exception {
if (log.isDebugEnabled()) {
log.debug("Entered onSubmit");
log.debug("Parameters:");
for (Enumeration e = request.getParameterNames(); e.hasMoreElements(); ) {
String element = (String) e.nextElement();
log.debug(element + "=" + request.getParameter(element));
}
}
Person person1 = (Person) command;
if (log.isDebugEnabled()) {
log.debug("Person from command: " + person1);
}
Person person2 = (Person) getCommand(request);
if (log.isDebugEnabled()) {
log.debug("Person from getCommand(): " + person2);
}
Person person3 = (Person) formBackingObject(request);
if (log.isDebugEnabled()) {
log.debug("Person from formBackingObject(): " + person3);
}
getExample().changePerson(person1);
// Display the Persons with the new additions
return new ModelAndView("personsView", "persons", getExample().getPersons());
}
On Submit, my log looks like this:
DEBUG PersonChangeController - Entered onSubmit
DEBUG PersonChangeController - Parameters:
DEBUG PersonChangeController - lastName=Simpson
DEBUG PersonChangeController - key=3
DEBUG PersonChangeController - firstName=Homer
DEBUG PersonChangeController - Person from command: 3 'Homer ,Homer' 'Simpson ,x'
DEBUG PersonChangeController - Person from getCommand(): 0 'null' 'null'
DEBUG PersonChangeController - Person from formBackingObject(): 0 'null' 'null'


Reply With Quote