My domain object does not store values โโthat are not explicitly specified in the JSP file between the GET and the POST operation on the same controller. Below is an example with error checking error
I have a domain object.
class foo { private int fieldA; private String fieldB;
controller
@Controller public class MyController { @Autowired private IDaoService daoService; @RequestMapping(value = "/display", method = RequestMethod.GET) public String newForm(@RequestParam("id") Long id, Model model, Principal principal) throws Exception {
Jsp
<form:form method="post" commandName="foo"> <fieldset> <legend>Invest</legend> <div class="fm-req"> <label for="fm-name">Field B</label> <spring:bind path="fieldB"> <input id="fm-name" type="text" name="${status.expression}" value="${status.value}" ></input> </spring:bind> </div> <div id="fm-submit" class="fm-req"> <INPUT type="submit" value="Submit" name="Submit" /> </div> </fieldset> </form:form>
I would think that the JSP gets an object created in newForm that has a set of fieldA (and possibly field B). The user has the option to change field B, and then click submit. I read Spring docs a lot and checked websites, but can't find out why foo.fieldA is null for the update method in the controller.
From what I understand about Spring MVC, this is a standard template, but please feel free to correct me.
Thanks in advance,
source share