나의질문답

request.setAttribute

예쁜꽃이피었으면 2014. 7. 29. 23:44

  • request.setAttribute / request.getAttribute

request.setAttribute("result", "0");
request.setAttribute("message", "결재 처리가 실패되었습니다.");
request.setAttribute("goodname", goodname);
request.setAttribute("price", price);
request.setAttribute("userid", userid);
request.setAttribute("recvphone", recvphone);

 

request.setAttribute("객체명",객체)'

이런 식으로 값을 세팅해야지만

jsp에서 값을 받을 수 있다.

 

-request.setParameter()와 getParameter()를 이용하면 String 값만 받을 수 있다.

 그래서 list를 받기 위해서는 setAttribute() , getAttribute()를 써야 한다.

 type이 object이기 때문에 반드시 형변환 필요.

 

jsp에서 호출하면 jsp에서 "객체명"을 이용해서 객체를 받을 수 있다.

<% Object x = request.getArrtiiubute(객체명);

 

 

받는 곳에서는(jsp)

<input neme = "goodname" value ="${goodname}">

*수정 안되게 하려면 readonly*

이렇게 하거나

${goodname}

*${ } 은 html에서 자바 변수를 쓸 때 필요하다.

 

 

http://blog.naver.com/emfnglf?Redirect=Log&logNo=71312154


반응형