BaseClass.java
protected <E> void setResponse(ModelMap model, List<E> ... resListArray) { Box resDatas = new Box(); int listIndex = 0; for (List E : resListArray) { resDatas.put(RepItemName.RES_LIST_PREFIX + String.format("%03d", ++listIndex), E); } //... }
callClass.java
public void getExam00002(ModelMap model) { Exam00002ReqVO reqParam = getRequestVO(Exam00002ReqVO.class); List<Exam00002Res1VO> resList1 = mtDao.selectList("mt.exam.em.EmNee.selectNewExamStudentChk1", reqParam); List<Exam00002Res2VO> resList2 = mtDao.selectList("mt.exam.em.EmNee.selectNewExamStudentChk2", reqParam); //여기처럼 List[] resList = {resList1, resList2}; setResponse(model, resList); }
또는 아래처럼 Arrays.asList를 사용해도 됨. BassClass.java
protected <E> void setResponse(ModelMap model, List<E> resListArray) { Box resDatas = new Box(); int listIndex = 0; for (E list: resListArray) { resDatas.put(RepItemName.RES_LIST_PREFIX + String.format("%03d", ++listIndex), list); } Box resParamBox = new Box(); resParamBox.put(EnpApiConst.SpParamName.ERR_CD, EnpApiConst.SpValue.SUCCESS_CD); resParamBox.put(EnpApiConst.SpParamName.ERR_MSG, EnpApiConst.SpValue.SUCCESS_MSG); //... }
callClass.java
import java.util.Arrays; public void getExam00002(ModelMap model) { Exam00002ReqVO reqParam = getRequestVO(Exam00002ReqVO.class); List<Exam00002Res1VO> resList1 = mtDao.selectList("mt.exam.em.EmNee.selectNewExamStudentChk1", reqParam); List<Exam00002Res2VO> resList2 = mtDao.selectList("mt.exam.em.EmNee.selectNewExamStudentChk2", reqParam); setResponse(model, Arrays.asList(resList1, resList2)); }