zoukankan      html  css  js  c++  java
  • Extjs4 store load 有中文字符提交后台乱码解决方法

    一、在load提交时对字符串进行decode处理。

    Js代码  收藏代码
    1. {name : encodeURIComponent(value)}  

    然后在后端进行反编码

    Java代码  收藏代码
    1. java.net.URLDecoder.decode(name, "utf-8");  

    根据这一做法确实可以解决这一问题。但是综合比较后个人认认为这不是一个很好的解决方法。这一做法就是每一个参数都需要重复上述步骤。比较烦。在对from提交与store提交对比后发现load提交默认为“get”.参考相应说明后。在数据源定义中更改method为"post".即可解决store带中文提交乱码问题。

    更改后的代码:

    Js代码  收藏代码
    1. Ext.define('W.gzgl.stores.common.MenuStore', {  
    2.     extend    : 'Ext.data.Store',  
    3.     pageSize  : 20,  
    4.     requires  : ['W.gzgl.models.common.MenuModel'],  
    5.     model     : 'W.gzgl.models.common.MenuModel',      
    6.     autoDestroy: true,  
    7.     autoLoad    : true,  
    8.     proxy : {  
    9.         type    : 'ajax',  
    10.         url     : 'manager/menuList.hs',  
    11.         actionMethods: {  
    12.             read: 'POST'  
    13.         },  
    14.         reader  : {  
    15.             type        : 'json',  
    16.             root        : 'rows',  
    17.             idProperty  : 'name'  
    18.         }  
    19.     }  
    20. });  
  • 相关阅读:
    bzoj 1098 [POI2007] 办公楼 biu
    「 Luogu P2574 」 XOR的艺术——线段树
    「 Luogu P2801 」 教主的魔法——分块
    Luogu P1438 无聊的数列
    「 Luogu P2420 」 让我们异或吧
    「 SPOJ GSS3 」 Can you answer these queries III
    「 HDOJ P2227 」 Find the nondecreasing subsequences
    「 HDOJ P3887 」 Counting Offspring
    一些性质及公式
    OI杂记
  • 原文地址:https://www.cnblogs.com/mannixiang/p/6588500.html
Copyright © 2011-2022 走看看