---
title: "1.jquery form serialize()方法提交到后台乱码解决办法"
author: "wukele"
date: "2012-12-14T11:23:51Z"
tags: []
categories: ["Web前端"]
slug: "1-jquery-form-serialize"
draft: false
lastmod: "2012-12-14T11:23:51Z"
id: 1747641
url: "https://wukele.iteye.com/blog/1747641"
---

我的tomcat设置的是 gbk编码

 

1.前台编码

因为jquery的表单的serialize方法原本就会进行encodeURIComponent方法，所以你再用encodeURIComponent就会变为中文。

jQuery.ajax({

url: '&lt;%=request.getContextPath()%&gt;/common.do',

data: encodeURI($('#editform').serialize()),

type: "POST",

async:false,

beforeSend: function() {  

  },

success: function(){

alert(33);

}

});

2.后台解码

 java.net.URLDecoder.decode(value, "UTF-8");