最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
jsp 读取地址栏参数
时间:2022-07-02 17:26:50 编辑:袖梨 来源:一聚教程网
/*
分析:当调用request.getParameter()函数时,会自动进行一次URI的解码过程,
调用时内置的解码过程会导致乱码出现。
而URI 编码两次后,request.getParameter()函数得到的是原信息URI编码一次的内容。
再用可控的解码函数 java.net.URLDecoder.decode()就可解出原始的正确的信息。
*/
jsp 读取地址栏参数
var params = encodeURI(encodeURI("method=post&filed=hit&keyword=" + keyword));
createXMLHttpRequest();
var url = "search.do";
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("content-length",params.length);
xmlHttp.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(params);
服务器端代码:
response.setContentType("text/html;charset=gb2312");
//ajax post传递的时候,一定是用utf8编码的,url 自己可以设定
String keyword = URLDecoder.decode((String)request.getParameter("keyword"),"utf-8");
相关文章
- 和平精英五周年福利活动一览 和平精英5周年庆有哪些活动 04-28
- 崩坏星穹铁道知更鸟遗器搭配推荐 崩坏星穹铁道知更鸟遗器怎么搭配 04-28
- 崩坏星穹铁道知更鸟光锥推荐 崩坏星穹铁道知更鸟带什么光锥 04-28
- 崩坏星穹铁道知更鸟突破材料一览 崩坏星穹铁道知更鸟需要哪些材料 04-28
- 王者荣耀群星祈愿活动怎么玩 04-28
- 《一念逍遥》5月20日全新密令是什么2023年5月20日全新密令 04-28