zoukankan      html  css  js  c++  java
  • 杂项:常见错误01

    ylbtech-杂项:常见错误01
    1.返回顶部
    1、 富文本框提交提示“从客户端() 中检测到有潜在危险的 Request.Form 值。”
    1.1、
    1.2、在 API 增加方法属性参数 “[ValidateInput(false)]
    [ValidateInput(false)]
            [HttpPost, Route("")]
            public JsonResult Create(Information model)
            {
                Service.Insert(model);
                return Ok("");
            }
    1.3、扩展 ValidateInputAttribute.cs
    #region 程序集 System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    // D:work-JFBJFBWebpackagesMicrosoft.AspNet.Mvc.5.2.3lib
    et45System.Web.Mvc.dll
    #endregion
    
    namespace System.Web.Mvc
    {
        //
        // 摘要:
        //     表示一个特性,该特性用于标记必须验证其输入的操作方法。
        [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
        public class ValidateInputAttribute : FilterAttribute, IAuthorizationFilter
        {
            //
            // 摘要:
            //     初始化 System.Web.Mvc.ValidateInputAttribute 类的新实例。
            //
            // 参数:
            //   enableValidation:
            //     若启用验证,则为 true。
            public ValidateInputAttribute(bool enableValidation);
    
            //
            // 摘要:
            //     获取或设置一个值,该值指示是否启用验证。
            //
            // 返回结果:
            //     如果启用了验证,则为 true;否则为 false。
            public bool EnableValidation { get; }
    
            //
            // 摘要:
            //     在需要授权时调用。
            //
            // 参数:
            //   filterContext:
            //     筛选器上下文。
            //
            // 异常:
            //   T:System.ArgumentNullException:
            //     filterContext 参数为 null。
            public virtual void OnAuthorization(AuthorizationContext filterContext);
        }
    }
    2、
    2. 【问题】ueditor二次加载(getEditor)渲染失败(加载失败)的原因解决方案返回顶部
    1、动态添加uedit的时候,第一次可以正常显示编辑框,之后每次都没有显示
    1.1、

    【问题】ueditor二次加载(getEditor)渲染失败(加载失败)的原因解决方案
    【解决方案】:再次使用时先删除之前的实例化对象,再进行再次实例化

    initCkEditor: function (opts) {
                //【问题】ueditor二次加载(getEditor)渲染失败(加载失败)的原因解决方案
                //【解决方案】:再次使用时先删除之前的实例化对象,再进行再次实例化
                UE.delEditor(opts.id);  // 1/2 先删除之前实例的对象
                var editor = UE.getEditor(opts.id, {
                    wordCount: false,
                    elementPathEnabled: false,
                    autosave: false,
                    zIndex: opts.zIndex === undefined ? 2000 : opts.zIndex,
                    initialFrameHeight: opts.height === undefined ? (utils.isMobileBrowser() ? 200 : 300) : opts.height,
                    toolbars: opts.toolbar === undefined ? [[
                        'source', '|', 'undo', 'redo', '|',
                        'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
                        'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
                        'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
                        'directionalityltr', 'directionalityrtl', 'indent', '|',
                        'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
                        'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
                        'simpleupload', '|', 'horizontal', '|',
                        'inserttable', "fullscreen", "insertvideo"
                    ]] : (opts.toolbar === 1 ? [[
                        'source', '|', 'undo', 'redo', '|',
                        'fontfamily', 'fontsize',
                        'bold', 'italic', 'underline', 'fontborder', 'forecolor', 'backcolor'
                    ]] : [[]])
                }); // 2/2添加编辑器
                return editor;
            },
            getEditorId: function (id) {
                var editorId = mPageManager.getPageUrl() + id;
                utils.getCurrObj().find("#" + id).attr("id", editorId);
                return editorId;
            }
    1.2、
    2、
     
    3、
    3. ueditor二次加载(getEditor)渲染失败(加载失败)的原因解决方案返回顶部
    1、
    1.1、
    1.2、
    大家自己看看官方的js文件ueditor.all.js有以下的代码
    /**  
         * @name getEditor  
         * @since 1.2.4+  
         * @grammar UE.getEditor(id,[opt])  =>  Editor实例  
         * @desc 提供一个全局的方法得到编辑器实例  
         *  
         * * ''id''  放置编辑器的容器id, 如果容器下的编辑器已经存在,就直接返回  
         * * ''opt'' 编辑器的可选参数  
         * @example  
         *  UE.getEditor('containerId',{onready:function(){//创建一个编辑器实例  
         *      this.setContent('hello')  
         *  }});  
         *  UE.getEditor('containerId'); //返回刚创建的实例  
         *  
         */  
        UE.getEditor = function (id, opt) {  
            var editor = instances[id];  
            if (!editor) {  
                editor = instances[id] = new UE.ui.Editor(opt);  
                editor.render(id);  
            }  
            return editor;  
        };  
      
      
        UE.delEditor = function (id) {  
            var editor;  
            if (editor = instances[id]) {  
                editor.key && editor.destroy();  
                delete instances[id]  
            }  
        };  

    这段可以看到,在调用UE.getEditor(‘_editor’)初始化UEditor时,先从放置编辑器的容器instances中获取,没有实例才实例化一个Editor,这就是引起问题的原因。
    在第一次跳转到编辑器界面时,正常的实例化了一个新的编辑器对象,并放入instances,调用editor.render(id)渲染编辑器的DOM;
    第二次初始化时却仅从容器中取到实例:var editor = instances[id]; 直接返回了editor对象,而编辑器的DOM并没有渲染。

    【解决方案】:
    再次使用时先删除之前的实例化对象,再进行再次实例化(测试可行)

    UE.delEditor('editor');   //先删除之前实例的对象
    UE.getEditor('editor');    //添加编辑器

    或者如下解决,对目标DOM进行手动渲染

    UE.getEditor('editor').render('editor');   //使用之前的对象(同时渲染DOM)
    2、
    4. 1.3 上传图片提示“上传错误”返回顶部
    1、上传图片提示“上传错误”
    1.1 问题截图

    1.2 解决方法:ueditor.config.js 文件没有正确配置“serverUrl”参数

    , serverUrl: (window.fileServer ? window.fileServer : 'http://localhost:8023/') + "fileuploader.ashx?accesstoken=" + $.cookie("token")
    2、
    5.返回顶部
     
    6.返回顶部
     
    7.返回顶部
     
    8.返回顶部
     
    9.返回顶部
     
    10.返回顶部
     
     
    11.返回顶部
     
    12.返回顶部
     
    13.返回顶部
     
    14.返回顶部
     
    15.返回顶部
     
     
    16.返回顶部
     
    warn 作者:ylbtech
    出处:http://ylbtech.cnblogs.com/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    折半枚举(双向搜索)
    弹性碰撞
    集合的整数表示
    反转(开关问题)
    尺取法
    floor函数用法
    二分搜索
    4. 差分约束系统
    二叉树的表达式求值
    关于移动app开发的一些不错的站点
  • 原文地址:https://www.cnblogs.com/storebook/p/8855969.html
Copyright © 2011-2022 走看看