Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem with Spring MVC. How can I create view from two or more object?
    primarykey
    data
    text
    <p>[spring 3.0.5] [jboss 5.1]</p> <p>A have a two class</p> <pre><code>public class User { private String name; private String surname; private Address address; ... sets and gets setters and getters } public class Address { private String street; ... setters and getters } </code></pre> <p>In Controller I have this code:</p> <pre><code>@Controller public class MyController { @RequestMapping(value = "/index") public ModelAndView showForm() { ModelAndView mav = new ModelAndView(); mav.setViewName("index"); User user = new User(); Address adr = new Address(); mav.addObject("user", user); mav.addObject("adr", adr); } </code></pre> <p>And now I want to create from with two input element in JSP</p> <pre><code>&lt;%@taglib uri="http://www.springframework.org/tags" prefix="spring"%&gt; &lt;%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%&gt; &lt;html&gt;&lt;head&gt;&lt;body&gt; &lt;form:form method="POST" commandName="user"&gt; &lt;form:label path="name" /&gt; &lt;form:input path="name" /&gt; &lt;form:label path="adr.street" /&gt; &lt;form:input path="adr.street" /&gt; &lt;/form:form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>When I runing a got a exception like this one:</p> <p>org.springframework.beans.NotReadablePropertyException: Invalid property 'adr' of bean class [form.User]: Bean property 'adr' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter? org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:707) org.springframework.be</p> <p>Can someone please explain to me why and how to improve the code?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload