日期:2014-05-19 浏览次数:20996 次
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@page import="net.sf.json.JSONArray"%> <!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=ISO-8859-1"> <title>Insert title here</title> <script type="text/javascript" src="/jquery/jquery-1.4.2.js"></script> <script type="text/javascript" src="/js/common/json2.js"></script> <script type="text/javascript"> $(function() { var arrsStr = $("#arrs").val(); //从隐藏域得到json字符串 var arrs = JSON.parse(arrsStr) ; //把json字符串转成json对象 //没有json.js,用 var arrs = null ;eval("arrs"+ arrsStr) for(var i = 0; i < arrs.length; i++){ var arr = arrs[i]; for(var j = 0; j < arr.length; j++){ document.write(arr[j] +"<br>"); } } } ); </script> </head> <body> <%! public static final int [][]array_JD = new int[3][3]; %> <% array_JD[0][0]=15; array_JD[0][1]=15; array_JD[0][2]=15; array_JD[1][0]=55; array_JD[1][1]=55; array_JD[1][2]=55; array_JD[2][0]=95; array_JD[2][1]=95; array_JD[2][2]=95; out.println(array_JD[2][2]); //net.sf.json.JSONArray java的jar包 JSONArray objlist = JSONArray.fromObject(array_JD);//转成json格式 //保存到隐藏域 %> <input id="arrs" type="hidden" value = <%= objlist%> /> </body> </html>