如何给struts2传递对象值,含数组

一、Java后端Action及对象后端

public class HomeAction {
    
    private Room room;浏览器

    /**
     * @return the room
     */
    public Room getRoom() {
        return room;
    }this

    /**
     * @param room the room to set
     */
    public void setRoom(Room room) {
        this.room = room;
    }
}.net

class Room{
    String number;
    List<User> users;
    /**
     * @return the number
     */
    public String getNumber() {
        return number;
    }
    /**
     * @param number the number to set
     */
    public void setNumber(String number) {
        this.number = number;
    }
    /**
     * @return the users
     */
    public List<User> getUsers() {
        return users;
    }
    /**
     * @param users the users to set
     */
    public void setUsers(List<User> users) {
        this.users = users;
    }
}对象

class User{
    
    String name;
    String age;
    List<String> phone;
    /**
     * @return the name
     */
    public String getName() {
        return name;
    }
    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }
    /**
     * @return the age
     */
    public String getAge() {
        return age;
    }
    /**
     * @param age the age to set
     */
    public void setAge(String age) {
        this.age = age;
    }
    /**
     * @return the phone
     */
    public List<String> getPhone() {
        return phone;
    }
    /**
     * @param phone the phone to set
     */
    public void setPhone(List<String> phone) {
        this.phone = phone;
    }
}get

 

二、http请求看到的格式以下,用F12观察浏览器io

room.number='1233';
room.users[0].name='my name is jcc';
room.users[0].age='25';
room.users[0].phone[0]='15528052635';
 class

只有这种格式后台才能接收到嵌套对象及List值后台