每日記載內(nèi)容總結(jié)40-創(chuàng)新互聯(lián)

1.ajax傳值map時(shí),在頁面解析每日記載內(nèi)容總結(jié)40
Map<Integer, List<Object[]>> objs = new HashMap<Integer, List<Object[]>>();
objs.put(1, page.getRows());
objs.put(2, pageOrders);
return renderMyPageData(success, msg, objs, page);
if(result.status == "true" || result.status == true){
var page = result.page;
var orders = null;
var rows = null;
                         $.each(result.data,function(key, value) {
if(key == 1){
                                 orders= value;
                             }else if(key == 2){
                                rows=     value;                         
                             }
                         });

2.object轉(zhuǎn)型int

靖西網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián)建站,靖西網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為靖西成百上千提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\成都外貿(mào)網(wǎng)站建設(shè)公司要多少錢,請(qǐng)找那個(gè)售后服務(wù)好的靖西做網(wǎng)站的公司定做!
Integer.valueOf(String.valueOf(obj[1])).intValue();

3.js有用方法:

格式化時(shí)間

//格式化CST日期的字串function formatCSTDate(strDate,format){
return formatDate(new Date(strDate),format);
}
 
//格式化日期,function formatDate(date,format){
var paddNum = function(num){
    num+= "";
return num.replace(/^(d)$/,"0$1");
  }
//指定格式字符var cfg = {
     yyyy : date.getFullYear()//年 : 4位    ,yy : date.getFullYear().toString().substring(2)//年 : 2位    ,M  : date.getMonth() + 1//月 : 如果1位的時(shí)候不補(bǔ)0    ,MM : paddNum(date.getMonth() + 1) //月 : 如果1位的時(shí)候補(bǔ)0    ,d  : date.getDate() //日 : 如果1位的時(shí)候不補(bǔ)0    ,dd : paddNum(date.getDate())//日 : 如果1位的時(shí)候補(bǔ)0    ,hh : date.getHours()//時(shí)    ,mm : date.getMinutes() //分    ,ss : date.getSeconds() //秒  }
  format|| (format = "yyyy-MM-dd hh:mm:ss");
return format.replace(/([a-z])(1)*/ig,function(m){return cfg[m];});
}

字符串開端

String.prototype.startWith=function(s){
if(s==null||s==""||this.length==0||s.length>this.length)
return false;
if(this.substr(0,s.length)==s)
return true;
else   return false;
return true;
 }

4.瀏覽器下載中文文件名文件時(shí),F(xiàn)irefox會(huì)出現(xiàn)亂碼,兼容firefox ie8-ie11 chrome的方法:

前端頁面,判斷瀏覽器類型,然后傳標(biāo)志位到后臺(tái),根據(jù)標(biāo)志位設(shè)置內(nèi)容

var browser = new Object();
browser.isMozilla= (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined') && (typeof HTMLDocument != 'undefined')? true : false;
browser.isIE= window.ActiveXObject ? true : false;
browser.isOpera= navigator.userAgent.toLowerCase().indexOf('opera') != -1;
browser.isSafari= navigator.userAgent.toLowerCase().indexOf('safari') != -1;
browser.isFirefox= navigator.userAgent.toLowerCase().indexOf('firefox') != -1;
//導(dǎo)出全部二維碼
function exporterweima() {
  if(browser.isFirefox){
    window.open('${ctx}/exporterweima.do?browserType=1');
    }else{
      window.open('${ctx}/exporterweima.do?browserType=0');
    }
  }
 try {
// path是指欲下載的文件的路徑。                File file = new File(path);
// 取得文件名。                String filename = file.getName();
// 取得文件的后綴名。                String ext = filename.substring(filename.lastIndexOf(".") + 1).toUpperCase();
                
                String allName= "";
if(StringUtils.isNotBlank(province)){
                    allName= province + "---銷售二維碼." + ext.toLowerCase();
                }else{
                    allName= "銷售二維碼." + ext.toLowerCase();
                }

// 以流的形式下載文件。                InputStream fis = new BufferedInputStream(new FileInputStream(path));
byte[] buffer = new byte[fis.available()];
                fis.read(buffer);
                fis.close();
// 清空response                response.reset();
// 設(shè)置response的Header  if(browserType != null){
                    if(browserType == 1){
              //針對(duì)Firefox設(shè)置編碼 response.addHeader("Content-Disposition", "attachment;filename="+ new String(allName.getBytes("GB2312"),"ISO-8859-1")); }else{ response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(allName, "UTF-8")); } }else{ response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(allName, "UTF-8")); } response.addHeader("Content-Length", "" + file.length()); OutputStream toClient= new BufferedOutputStream(response.getOutputStream()); response.setContentType("application/x-tar"); toClient.write(buffer); toClient.flush(); toClient.close(); f.delete(); }catch (IOException ex) { ex.printStackTrace(); }

5.打包文件

使用ant包打包文件,可以設(shè)置編碼格式,在linux下,設(shè)置編碼格式,打包中文文件名的時(shí)候,不會(huì)亂碼。

org.apache.tools.zip.ZipOutputStream使用的默認(rèn)編碼是系統(tǒng)編碼(window是gbk而linux是utf- 8),在window下解壓時(shí)用的是gbk,因些如果是在linux下壓縮的文件,到window下解壓就會(huì)出現(xiàn)亂碼,因些在壓縮時(shí)就為其指定編碼為 gbk

(原鏈接:ZipOutputStream 文件中文亂碼)

String targetName = resourcesFile.getName()+".rar"; //目的壓縮文件名
//FileOutputStream outputStream = new FileOutputStream(targetPath+"\"+targetName);        FileOutputStream outputStream = new FileOutputStream(targetPath+File.separator+targetName);
        ZipOutputStream out= new ZipOutputStream(new BufferedOutputStream(outputStream));
        out.setEncoding("GBK");
        createCompressedFile(out, resourcesFile,"");
//刪除erweima文件夾下面的圖片        String[] tempList = resourcesFile.list();
        File temp= null;
for (int i = 0; i < tempList.length; i++) {
if (resourcesPath.endsWith(File.separator)) {
              temp= new File(resourcesPath + tempList[i]);
           }else {
               temp= new File(resourcesPath + File.separator + tempList[i]);
           }
if (temp.isFile()) {
              temp.delete();
           }
        }
//
        out.close();

分享題目:每日記載內(nèi)容總結(jié)40-創(chuàng)新互聯(lián)
文章位置:http://www.muchs.cn/article10/dsscgo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供動(dòng)態(tài)網(wǎng)站、品牌網(wǎng)站制作、用戶體驗(yàn)、定制網(wǎng)站、域名注冊(cè)、網(wǎng)站導(dǎo)航

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

營(yíng)銷型網(wǎng)站建設(shè)