상세 컨텐츠

본문 제목

jsp toBean

관리X 과거글

by 까먹기전에 2015. 3. 24. 10:22

본문

반응형

http://localhost:8282/tobean/b.jsp?aa={"bb":"cc","dd":"ee"}



=========================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='{"bb" : "cc" , "dd" : "ee"}';

$.ajax({

url :"b.jsp",

data:{"aa" : str},

cache:false,

success : function(data){

alert(data)

}

})


})

</script>

</body>

</html>


========================b.jsp===================================


<%@ 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);

String s1=(String)jsonObject.get("bb");

String s2=(String)jsonObject.get("dd");

out.println(s1+","+s2);

%>



관련글 더보기