由于对象没有没有new出来直接使用,提示该错误
private List<AuthInfo> authInfoList;
/*此处必须new粗来*/
authInfoList = new ArrayList<AuthInfo>();
AuthInfo authInfo = new AuthInfo();authInfo.setGateName(gate.getName()); authInfo.setType(authorizations.get(i).getType()); authInfo.setTeam(authorizations.get(i).getTeam()); authInfo.setWeek(authorizations.get(i).getWeek()); authInfo.setStartTime(authorizations.get(i).getStartTime()); authInfo.setEndTime(authorizations.get(i).getEndTime()); authInfoList.add(authInfo);
@XmlRootElement(name="commandlist") @XmlAccessorType(XmlAccessType.FIELD) public class CommandList { @XmlElement(name="command") private List<Command> commandList; public List<Command> getCommandList(){return commandList;} public void setCommandList(List<Command> commandList){ this.commandList = commandList; } }
CommandList commandList = new CommandList();commandList.setCommandList(new ArrayList<Command>()); //必须加,否则空指针for(int i=0; i<delIoBean.getGateNameList().size(); i++){ Command command = new Command(); command.setCmd("delIo"); command.setGate(delIoBean.getGateNameList().get(i)); command.setData(""); commandList.getCommandList().add(command); }