【问题标题】:EXT JS - How to get the _dc parameter from the request?EXT JS - 如何从请求中获取 _dc 参数?
【发布时间】:2017-03-10 19:57:19
【问题描述】:

感谢您的帮助!

我正在尝试连接到使用完整 URL 将 Autorization 令牌编码回服务器的 RESTfull Web 服务。 然后,服务器将其接收到的 que URL 与在请求中发送的 URL 进行比较。

但是我无法从请求中获取 _dc 参数! 知道怎么做吗?

提前致谢!

【问题讨论】:

    标签: javascript extjs authorization restful-authentication extjs6


    【解决方案1】:

    我查看了源代码,看起来 _dc 参数只是 Ext.Date.now()

    if (me.getNoCache()) {
        url = Ext.urlAppend(url, Ext.String.format("{0}={1}", me.getCacheString(), Ext.Date.now()));
    }
    

    获得它的一种方法是覆盖 buildUrl() 方法。例如:

    init: function () {
        Ext.define('Override.Ext.data.proxy.Server', {
            override: 'Ext.data.proxy.Server',
    
            buildUrl: function (request) {
                var me = this,
                    url = me.getUrl(request);
    
                //<debug>
                if (!url) {
                    Ext.raise("You are using a ServerProxy but have not supplied it with a url.");
                }
                //</debug>
    
                var dc = Ext.Date.now();
    
                if (me.getNoCache()) {
    
                    url = Ext.urlAppend(url, Ext.String.format("{0}={1}", me.getCacheString(), dc));
                }
    
                // do something with dc here
    
                return url;
            }
        });
    }
    

    (这将放在您的 Application.js 中)

    另一种更简单的方法,但我不知道它是否适用于您的情况,就是通过将 noCache: false 放入您的商店代理配置中来简单地禁用 _dc 参数。

    希望对您有所帮助!

    【讨论】:

      猜你喜欢
      • 2011-01-04
      • 1970-01-01
      • 2014-04-18
      • 2020-08-26
      • 2013-08-03
      • 1970-01-01
      • 1970-01-01
      • 2019-08-05
      • 1970-01-01
      相关资源
      最近更新 更多