Results 1 to 2 of 2

Thread: Command class property type

  1. #1
    Join Date
    Nov 2007
    Posts
    28

    Default Command class property type

    Hi

    In the Javadoc of BaseCommandController explained that a command class can basically be any Java class; preferably a JavaBean in order to be able to populate bean properties with request parameters.

    That means, if I have the following command class,

    Code:
    public class UserCommand {
    
        private int age;
    
        private Short count;
    
        public int getAge() {
            return age;
        }
        public void setAge(int age) {
            this.age = age;
        }
        public Short getCount() {
            return count;
        }
        public void setCount(Short count) {
            this.count = count;
        }
    }
    Spring controller will automatically populate the command object from the request?

  2. #2
    Join Date
    May 2008
    Posts
    12

    Default Not Exactly

    Spring will do a lot of work behind the scene to fetch those values for you.
    You just need to map the fields from your jsp page with the property(i.e. field of the command object).

    There are couple of methods to do this.
    You can use form taglib and then use it's path element.
    Look to map throgh <spring:bind>

    Hope this clears your doubt.
    All the best, Happy Learning!!!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •