==========================a.jsp==================================
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<body>
<script type="text/javascript" src="jquery-2.1.3.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var str='{"list":[{"id":"aa","pw":"bb","addr":"cc","tel":"dd"},{"id":"bb","pw":"bb","addr":"cc","tel":"dd"}]}';
$.ajax({
url :"b.jsp",
data:{"aa" : str},
cache:false,
success : function(data){
alert(data)
}
})
})
</script>
</body>
</html>
==========================b.jsp===================================
<%@page import="kr.co.seoulit.member.to.MemberBean"%>
<%@ page import="net.sf.json.*" %>
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<%
String str=request.getParameter("aa");
JSONObject jsonObject=JSONObject.fromObject(str); //리턴 오브젝트
JSONArray array = jsonObject.getJSONArray("list");
for(Object obj : array){
JSONObject json = (JSONObject)obj;
MemberBean member = (MemberBean)jsonObject.toBean(json,MemberBean.class);
out.write(member.getId()+member.getPw()+"//");
}
%>
jsp sitemesh 공부 내용, 좋은 기능 (0) | 2015.03.26 |
---|---|
jsp toJSON 결과 화면 (0) | 2015.03.24 |
jsp toBean (0) | 2015.03.24 |
jsp 모델2를 이용한 파일업로드 가능한 답변형 게시판 (0) | 2015.03.21 |
자바 JSP filter 공부, 톰캣 , filter 실행 순서 (0) | 2015.03.19 |