jsp
<form action=""> <input id="dbServerList[0].name" value="server1" /> <input id="dbServerList[0].parent" value="abstractServer" /> <input id="dbServerList[0].factoryConfig.propertyList[0].name" value="valueipAddress"/> <input id="dbServerList[0].factoryConfig.propertyList[0].value" value="192.168.202.129"/> <input id="dbServerList[0].factoryConfig.propertyList[1].name" value="user" /> <input id="dbServerList[0].factoryConfig.propertyList[1].value" value="root" /> <input id="dbServerList[0].factoryConfig.propertyList[2].name" value="password" /> <input id="dbServerList[0].factoryConfig.propertyList[2].value" value="xxxxxx" /> <input id="dbServerList[0].factoryConfig.propertyList[3].name" value="characterEncoding" /> <input id="dbServerList[0].factoryConfig.propertyList[3].value" value="utf8" /> <input id="dbServerList[0].factoryConfig.propertyList[4].name" value="port" /> <input id="dbServerList[0].factoryConfig.propertyList[4].value" value="3306" /> <input id="dbServerList[0].factoryConfig.propertyList[5].name" value="belongUsers" /> <input id="dbServerList[0].factoryConfig.propertyList[5].value" value="'root','root1'" /> <input id="dbServerList[1].name" value="server2" /> <input id="dbServerList[1].parent" value="abstractServer" /> <input id="dbServerList[1].factoryConfig.propertyList[0].name" value="valueipAddress"/> <input id="dbServerList[1].factoryConfig.propertyList[0].value" value="192.168.202.129"/> <input id="dbServerList[1].factoryConfig.propertyList[1].name" value="user" /> <input id="dbServerList[1].factoryConfig.propertyList[1].value" value="root" /> <input id="dbServerList[1].factoryConfig.propertyList[2].name" value="password" /> <input id="dbServerList[1].factoryConfig.propertyList[2].value" value="xxxxxx" /> <input id="dbServerList[1].factoryConfig.propertyList[3].name" value="characterEncoding" /> <input id="dbServerList[1].factoryConfig.propertyList[3].value" value="utf8" /> <input id="dbServerList[1].factoryConfig.propertyList[4].name" value="port" /> <input id="dbServerList[1].factoryConfig.propertyList[4].value" value="3306" /> <input id="dbServerList[1].factoryConfig.propertyList[5].name" value="belongUsers" /> <input id="dbServerList[1].factoryConfig.propertyList[5].value" value="'root','root1'" /> </form>
controller
@RequestMapping(value="/dbservers", method=RequestMethod.PUT) public ModelAndView updateDBServers(DBServers dbServers){ boolean bol = dBServerService.updateDBServers(dbServers.getDbServerList()); return new ModelAndView("test", "a", bol); }
接收参数是DBServer 对象
DBServers bean
public class DBServers implements Serializable{ private String name; private List<DBServer> dbServerList; //set get }
DBServer bean
public class DBServer implements Serializable{ private String name; private String abstractive; private String parent; private String virtual; private FactoryConfig factoryConfig; private PoolConfig poolConfig; //set get }
FactoryConfig bean
public class FactoryConfig implements Serializable {
private String clazz;
private List<Property> propertyList;
//set get
}
Property bean
public class Property implements Serializable{ private String name; private String value; private Bean bean; //set get }