阳光VIP

少壮不努力,老大徒伤悲。平日弗用功,自到临期悔。
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

prototype 异步提交表单 中文乱码

Posted on 2012-02-12 19:48  阳光VIP  阅读(174)  评论(0编辑  收藏  举报

test.html

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PROTOTYPE POST</title>
<script language="javascript" type="text/javascript" src="js/prototype.js"></script>
</head>
<body>
<script type="text/javascript">
function postNewContact(){
var form = $(’form’);
var url='result.jsp';
var myAjax = new Ajax.Request(url,{method:'post',
parameters: Form.serialize(form),
onComplete:showResponse});
}
function showResponse(originalRequest){
alert(originalRequest.responseText);
}
</script>
<form method="post" id="form" name="form">
<input type="text" name="act"> 
<input onclick="postNewContact();" name="pbut" type="button" value="POST" />
</form>
</body>
</html>

 

 

 

result.jsp

 

<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%=request.getParameter("act")%>

 

 

prototype提交为utf-8编码