Ajax使用POST提交中文乱码问题
编程技术  /  houtizong 发布于 3年前   56
<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>AJAX提交页面</title><meta http-equiv="Content-Type" content="text/html; charset=GB18030"><script type="text/javascript">function justdo(){ var post = "name=王力猛&[email protected]&bokee=http://wallimn.bokee.com"; post = encodeURI(post); post = encodeURI(post); //两次,很关键 var xmlObj = new ActiveXObject("Msxml2.XMLHTTP"); var URL = "act.jsp"; //文件名需要调整成测试时的相应位置 xmlObj.open("POST",URL,true); xmlObj.setRequestHeader("Cache-Control","no-cache"); xmlObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded;"); xmlObj.send(post); //注意:POST方式,使用这个来发送内容}</script></head> <body><input type="button" value="提交" onclick="justdo()" /></body></html>
<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><%@page import="java.net.URLDecoder"%><html><head><title>ajax deal</title><meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0"></head><body><%//遍历输出参数内容。for (Enumeration e = request.getParameterNames(); e.hasMoreElements();) { String h = (String)e.nextElement(); String v = request.getParameter(h); String mm = java.net.URLDecoder.decode(v, "UTF-8"); System.out.println("请求参数: " + h + " = " + mm);}%></body></html>
请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!
技术博客集 - 网站简介:
前后端技术:
后端基于Hyperf2.1框架开发,前端使用Bootstrap可视化布局系统生成
网站主要作用:
1.编程技术分享及讨论交流,内置聊天系统;
2.测试交流框架问题,比如:Hyperf、Laravel、TP、beego;
3.本站数据是基于大数据采集等爬虫技术为基础助力分享知识,如有侵权请发邮件到站长邮箱,站长会尽快处理;
4.站长邮箱:[email protected];
文章归档
文章标签
友情链接