0

我对此很生气:

使用 JDK 1.7 的 Tomcat 5.5、JRE 1.6(合规级别)

标题:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
...
<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<script src="js/jquery-ui/jquery-1.9.0.js"></script>

json请求:

params = $("#formList").serializeArray();
$.getJSON(url, params, function(data) {...});

当我将 ñ 传递给别名参数时,在我的 localhost 机器(win)上工作正常,但在生产服务器(linux)中,我得到了 param 或类似内容的双重编码:

WebBrowserRequest(对本地主机和生产的相同请求):

userList.action?pagination.currentPage=1&pagination.sortColumn=&pagination.sortColumnOrder=& user.alias=%C3%B1 &user.email=&selectedRole=-1&selectedCountry=-1&selectedTown=-1&selectedLanguage=-1&selectedUserEnabled=0&__multiselect_selectedCategories=&jsonRequest=true&back=false

服务器端 url 输出(本地主机):

userList.action?pagination.currentPage=1&jsonRequest=true&user.email=&selectedLanguage=-1&selectedTown=-1&selectedCountry=-1&pagination.sortColumn=&selectedRole=-1&back=false& user.alias=ñ &selectedUserEnabled=0&pagination.sortColumnOrder=&__multiselect_selectedCategories=

服务器端 url 输出(生产):

userList.action?jsonRequest=true&selectedTown=-1&pagination.sortColumn=& user.alias=ñ &back=false&pagination.sortColumnOrder=&pagination.currentPage=1&user.email=&selectedLanguage=-1&selectedCountry=-1&selectedRole=-1&selectedUserEnabled=0&__multiselect_selectedCategories=

4

1 回答 1

0

最后通过 $.ajax (POST) 解决了更改 getJSON (GET) 请求:

获取JSON:

$.getJSON(url, params, function(data) {
    showData(data);
}).error(function(data) {
    showFail(data);
});

阿贾克斯:

$.ajax({
    type: "POST",
    url: url,
    data: params
}).done(function( data ) {
    showData(data,page);
}).fail(function(jqXHR, textStatus) {
    showFail(jqXHR, textStatus);
});
于 2013-05-15T09:58:39.203 回答