<SCRIPT>
function getValue(){
var userName = $("#userName").val();
//$.post("loginAjax.action?userName="+window.encodeURI(userName),null,function(response){
$.post("loginAjax",{'userName':window.encodeURI(userName)},function(response){//解决中文
$("#result").html(response);
}
);
}
</SCRIPT>
<s:form action="loginAjax" method="post">
<input type="text" name="userName" id="userName"/>
<input type="button" value="searchRight" onClick="getValue();"/>
</s:form>
<div id="result">
</div>
Action里
userName = java.net.URLDecoder.decode(userName,"UTF-8");
办法二:
页面均为gb2312编码
<%@ page language="java" import="java.util.*" contentType="text/html; charset=gb2312" pageEncoding="gb2312"%>
<SCRIPT>
function getValue(){
var userName = $("#userName").val();
$.post("loginAjax",{'userName':userName},function(response){//解决中文
$("#result").html(response);
}
);
}
</SCRIPT>
Action也不用转码