每日记载内容总结40-创新互联

1.ajax传值map时,在页面解析每日记载内容总结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转型int

靖西网站建设公司创新互联建站,靖西网站设计制作,有大型网站制作公司丰富经验。已为靖西成百上千提供企业网站建设服务。企业网站搭建\成都外贸网站建设公司要多少钱,请找那个售后服务好的靖西做网站的公司定做!
Integer.valueOf(String.valueOf(obj[1])).intValue();

3.js有用方法:

格式化时间

//格式化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位的时候不补0    ,MM : paddNum(date.getMonth() + 1) //月 : 如果1位的时候补0    ,d  : date.getDate() //日 : 如果1位的时候不补0    ,dd : paddNum(date.getDate())//日 : 如果1位的时候补0    ,hh : date.getHours()//时    ,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.浏览器下载中文文件名文件时,Firefox会出现乱码,兼容firefox ie8-ie11 chrome的方法:

前端页面,判断浏览器类型,然后传标志位到后台,根据标志位设置内容

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;
//导出全部二维码
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();
// 设置response的Header  if(browserType != null){
                    if(browserType == 1){
              //针对Firefox设置编码 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包打包文件,可以设置编码格式,在linux下,设置编码格式,打包中文文件名的时候,不会乱码。

org.apache.tools.zip.ZipOutputStream使用的默认编码是系统编码(window是gbk而linux是utf- 8),在window下解压时用的是gbk,因些如果是在linux下压缩的文件,到window下解压就会出现乱码,因些在压缩时就为其指定编码为 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();

分享题目:每日记载内容总结40-创新互联
文章位置:https://www.cdcxhl.com/article10/dsscgo.html

成都网站建设公司_创新互联,为您提供动态网站品牌网站制作用户体验定制网站域名注册网站导航

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

营销型网站建设