页面加载时如何获取Servlet返回的json数据详细代码(开发servlet三种方法)

页面加载时如何获取Servlet返回的json数据详细代码(开发servlet三种方法)

首页维修大全综合更新时间:2025-07-29 18:02:35

页面加载时如何获取Servlet返回的json数据详细代码

在servlet里面进行重定向response.sendRedirect("home.html?param=json字符串")

;然后再html的js中,通过location.search获取param的value获取url后面参数的value,可以用以下方法function getParam(name)

{ var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)")

; var r = window.location.search.substr(1).match(reg)

; if(r!=null)return unescape(r[2]); return null;

}var p=getParam('param');

大家还看了
也许喜欢
更多栏目

© 2021 3dmxku.com,All Rights Reserved.