SSISO Community

시소당

String.valueOf()

보통

HashMap에  ("key",  value)
이렇게  들어가지만,,,  for  루프를  돌려서  넣어야  할경우에는

  

HashMap  infos  =  new  HashMap();
HashMap  infosChild1  =  new  HashMap();
HashMap  infosChild2  =  new  HashMap();

  

String  cnt  =  request.getParameter("cnt");

  

for(int  i  =  0;  i<Integer.parseInt(cnt);  i++){
  infosChild1.put  (String.valueOf(i),request.getParameter("name"  +  i));
  infosChild2.put  (String.valueOf(i),request.getParameter("seq"  +  i));
}
infos.put("infosChild1",  infosChild1);
infos.put("infosChild2",  infosChild2);

  

이렇게  HashMap에  넣었다가  다시  한번  더  HashMap에  넣는다.

그리고,  그  값을  다시  뽑아서,  Ejb에서  사용하는데,,,,
서블릿에서  ejb를  호출할때,  위의  infos를  인자로  넘겨주고,  ejb에서는    다음과  같이한다.
인자로  받은  infos로  부터,  하나씩  뽑아낸다.

  

HashMap  infosChild1  =  (HashMap)  infos.get("infosChild1");
HashMap  infosChild2  =  (HashMap)  infos.get("infosChild2");

  

for(int  i  =  0;  i  <  infosChild1.size();  i++){
  infos.put("name",  infosChild1.get(Integer.toString(i)));
  infos.put("seq",  infosChild2.get(Integer.toString(i)));
}

출처  String.valueOf()|작성자  유쾌한

831 view

4.0 stars