zoukankan      html  css  js  c++  java
  • 项目过程中一些收获

      没有高深的东西,仅仅是小知识、小应用。都是项目开发过程中记录下来的,大都来源于网上。整理下让自己看着方便,也分享下,希望能有点帮助。

      一、获取web根地址 ,因为有些创建的是虚拟目录,有些创建的站点

            public static string WebsiteRoot()
            {
                HttpRequest request
    =HttpContext.Current.Request;
                
    string root = request.Url.GetLeftPart(UriPartial.Authority); 
                
    if (request.ApplicationPath == null || request.ApplicationPath == "/")
                {
                    
    //安装在web站点
                    return root;
                }
                
    //安装在虚拟目录
                return string.Concat(root, request.ApplicationPath);            
            }

     

      二、JS判定IE是否已经关闭

            window.onunload = function() {
                
    var clientX = event.clientX;
                
    if (clientX < 0 || clientX > 3000) {
                    
    /*用户关闭了IE.
                     *已经在IE6,7下测试过两种关闭方式:
                     *1.点击关闭按键   2.ALT+F4
                    
    */

                    
    //需要执行的代码
                    alert("已经关闭");
                }
            }

      三、日志记录

      可以使用NLog做为日志工具,对其进行简单封装就OK了

      四、EXCEL导出

      可以使用CarlosAg.ExcelXmlWriter,包括代码自动生成工具

      

      五、XML编辑工具

      Altova XMLSpy,   破解版下载地址:http://www.verycd.com/topics/2838119/

        Altova MapForce ,破解版文件太大,无法上传,地址忘记了

       

        六、jQuery

      JS中的匿名函数又称为闭包函数 例子:(function(arg){})("1"); jQuery扩展可以这样书写 (function($){ ... })(jQuery);  

    var jQuery = window.jQuery = window.$ = function(selector, context)  {  
       
    // ...  // other internal initialization code goes here 

    }; 
    //可以将jQuery理解为类 

    jQuery.fn 
    = jQuery.prototype

    jQuery.func1
    =function(){

         ..... 

    }  
    //可以将其理解为jQuery静态函数

    jQuery.fn.func2
    =function(){

          ..... 

    }  
    //可以将其理解为jQuery实例函数


      七、Oracle

      字符填充:可以使用函数lpad rpad,具体功能指若字符串长度小于指定长度,则用指定的字符进行补全,可以在网上搜索下

        将十进制转化为二进制函数 :   

     create or replace function ufun_tentobin(ix in numberreturn varchar2 is

      vars 
    varchar2(1000);

      xs   
    number(10);

    begin

      
    if ix<=0 then

      
    begin

         
    return '0';

      
    end;

      
    end if;

      vars :
    = '';

      xs   :
    = ix;

      
    while xs > 0 loop

        vars :
    = cast(mod(xs, 2as varchar2|| vars;

        xs   :
    = floor(xs / 2);

      
    end loop;

      
    return vars;

    end;


      使用查询语句将二进制转化为十进制:

    select sum(data1) 
    from (select substr(二进制字符串, rownum, 1* power(2, length(二进制字符串) - rownum) data1
    from dual
    connect 
    by rownum <= length(二进制字符串)); 

      

      八、jquery easyui

      datagrid控件使用Post获取.json文件需要进行一些设置,可以看看这篇文章

      http://blog.csdn.net/zhhhhao/archive/2009/04/06/4051352.aspx

      jQuery中ajax的提交方式post、get,在服务端获取查询参数的方式不同:

            public static System.Collections.Specialized.NameValueCollection QueryParams(HttpContext context)
            {
                HttpRequest request 
    = context.Request;
                
    if (request.RequestType == "GET")
                {
                    
    return request.QueryString;
                }
                
    return request.Form;
            }


      

      


      

      

  • 相关阅读:
    Server Tomcat v8.0 Server at localhost was unable to start within 45 seconds. If the server requires more time, try increasing the timeout in the server editor.
    用户画像——“打标签”
    python replace函数替换无效问题
    python向mysql插入数据一直报TypeError: must be real number,not str
    《亿级用户下的新浪微博平台架构》读后感
    【2-10】标准 2 维表问题
    【2-8】集合划分问题(给定要分成几个集合)
    【2-7】集合划分问题
    【2-6】排列的字典序问题
    【2-5】有重复元素的排列问题
  • 原文地址:https://www.cnblogs.com/WGZ_Home/p/1855852.html
Copyright © 2011-2022 走看看