Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3946858
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:10:59+00:00 2026-05-20T01:10:59+00:00

[spring 3.0.5] [jboss 5.1] A have a two class public class User { private

  • 0

[spring 3.0.5]
[jboss 5.1]

A have a two class

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  
}

In Controller I have this 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);
}

And now I want to create from with two input element in JSP

<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> <%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>

    <html><head><body>
    <form:form method="POST" commandName="user">
    <form:label path="name" />
    <form:input path="name" />
    <form:label path="adr.street" />
    <form:input path="adr.street" />
    </form:form>
    </body>
    </html>

When I runing a got a exception like this one:

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

Can someone please explain to me why and how to improve the code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T01:11:00+00:00Added an answer on May 20, 2026 at 1:11 am

    Wrap your objects in a wrapper form class and pass it in the model.

    public class MyForm
    {
       public user;
       public address;
       // getters, setters, etc.
    }
    

    Then

    ModelAndView mav = new ModelAndView(); // ModelAndView
    mav.addObject("myForm", new MyForm()); // e.g.
    

    In your model, should address be attached to a user? In other words, it seems to me like a User has a one to many relationship to Address, and you should let your data access layer handle these concerns.

    @Entity
    @Table(name = "user")
    public class User
    {
       @Id @Column(name="user_id")
       public Long id;
    
       @OneToMany
       @JoinColumn(name = "user_id") // so the address table would have a user_id foreign key
       public Address address;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Spring: In my context.xml, I have: <util:set id=someIDs set-class=java.util.HashSet value-type=java.lang.String> <value>W000000001</value> <value>W000000003</value> <value>W000000009</value> </util:set>
I have my application running properly in Jboss. To to write spring webservice client,
I have a spring web application running on JBoss which is creating a csv
I have a working Spring MVC application(doing everything I wanted when deployed to jboss)
I have a JMS Message Listener under JBoss 5.1, configured by Spring. Although the
JBOSS is throwing a: java.lang.NoSuchMethodError: org.w3c.dom.Document.getDocumentURI()Ljava/lang/String; Error when loading a wsdl. Can I configure
Spring has a very handy convenience class called PropertyPlaceholderConfigurer , which takes a standard
In Spring 2.0, is there a quick way to have a list of the
I have two entities, Entity1 and Entity2, on a one to many relationship. On
I have a web application using JPA and JTA with Spring. I would like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.