Ajax传输中文乱码问题的解决办法(2)

function saveForm(){ if(document.theformadd.onsubmit()){ disableAllBtn(true); j$.ajax({ type:"get", url:"add_form_do.jsp", data:{ problem_id : j$("#problem_id").val(), product_id : "<%=product_id%>", productId : j$("#productId").val(), depart_id : j$("#depart_id").val(), fk_busi_id : j$("#fk_busi_id").val(), fk_type : j$("#fk_type").val(), fk_source : j$("#fk_source").val(), fk_info : encodeURI(j$("#fk_info").val()), fk_name : encodeURI(j$("#fk_name").val()), fk_bank_name : encodeURI(j$("#fk_bank_name").val()), fk_bank_acct : encodeURI(j$("#fk_bank_acct").val()), sk_name : encodeURI(j$("#sk_name").val()), sk_bank_name : encodeURI(j$("#sk_bank_name").val()), sk_bank_acct : encodeURI(j$("#sk_bank_acct").val()), fk_money : j$("#fk_money").val(), fk_summary : encodeURI(j$("#fk_summary").val()), fk_date : j$("#fk_date").val(), input_man : "<%=input_operatorCode%>" }, success:function(ret){ if(ret == 1) { sl_alert("保存成功!"); }else{ sl_alert(ret); } window.returnValue=true; window.close(); } }); } }

修复后add_form_do.jsp中获取数据:

<%@ page contentType="text/html; charset=GBK" import="java.math.*,com.enfo.intrust.intrust.vo.*,java.io.*, com.enfo.intrust.web.*,java.util.*,com.enfo.intrust.dao.*,com.enfo.intrust.intrust.*,com.enfo.intrust.tools.*,com.enfo.intrust.project.*" %> <script type="text/javascript" src="https://www.jb51.net/<%=request.getContextPath()%>/ext2.0/ext-base.js"></script> <script type="text/javascript" src="https://www.jb51.net/<%=request.getContextPath()%>/ext2.0/ext-all.js"></script> <%@ include file="/includes/operator.inc" %> <% try{ product_id = Utility.parseInt(Utility.trimNull(request.getParameter("product_id")),product_id); UnpostwarrantLocal local = EJBFactory.getUnpostwarrant(); Integer problem_id = Utility.parseInt(request.getParameter("problem_id"),new Integer(0)); Integer depart_id = Utility.parseInt(request.getParameter("depart_id"),new Integer(0)); //部门 Integer productId = Utility.parseInt(Utility.trimNull(request.getParameter("productId")),product_id); String fk_busi_id = Utility.trimNull(request.getParameter("fk_busi_id")); //字典1206 费用 String fk_type = Utility.trimNull(request.getParameter("fk_type")); //付款方式 2103 String fk_source = Utility.trimNull(request.getParameter("fk_source")); //付款依据 2104 String fk_info = Utility.trimNull(request.getParameter("fk_info")); //票据号码 String fk_name = Utility.trimNull(request.getParameter("fk_name")); //付款单位 String fk_bank_name = Utility.trimNull(request.getParameter("fk_bank_name")); //付款银行名称 String fk_bank_acct = Utility.trimNull(request.getParameter("fk_bank_acct")); //付款银行账号 String sk_name = Utility.trimNull(request.getParameter("sk_name")); //收款单位 String sk_bank_name = Utility.trimNull(request.getParameter("sk_bank_name")); //收款银行名称 String sk_bank_acct = Utility.trimNull(request.getParameter("sk_bank_acct")); //收款银行账号 BigDecimal fk_money = Utility.parseDecimal(Utility.trimNull(request.getParameter("fk_money")).replaceAll(",",""),new BigDecimal(0)); //金额 String fk_summary = Utility.trimNull(request.getParameter("fk_summary")); //备注 Integer fk_date = Utility.parseInt(request.getParameter("fk_date"),new Integer(Utility.getCurrentDate())); //要求付款日期 local.setProblem_id(problem_id); //local.setProduct_id(product_id); local.setProduct_id(productId); local.setDepart_id(depart_id); local.setFk_busi_id(fk_busi_id); local.setFk_type(fk_type); local.setFk_source(fk_source); local.setFk_info(java.net.URLDecoder.decode(fk_info, "UTF-8")); local.setFk_name(java.net.URLDecoder.decode(fk_name, "UTF-8")); local.setFk_bank_name(java.net.URLDecoder.decode(fk_bank_name, "UTF-8")); local.setFk_bank_acct(java.net.URLDecoder.decode(fk_bank_acct, "UTF-8")); local.setSk_name(java.net.URLDecoder.decode(sk_name, "UTF-8")); local.setSk_bank_name(java.net.URLDecoder.decode(sk_bank_name, "UTF-8")); local.setSk_bank_acct(java.net.URLDecoder.decode(sk_bank_acct, "UTF-8")); local.setFk_money(fk_money); local.setFk_summary(java.net.URLDecoder.decode(fk_summary, "UTF-8")); local.setFk_date(fk_date); local.setInput_man(input_operatorCode); local.addFinacialcardInfoGuotou(); out.clear(); response.getWriter().write("1"); }catch(Exception e){ out.clear(); response.getWriter().write(e.getMessage()); } %>

注意事项:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wjpjzy.html