PictureBOController

package com.smart.ibus.client.web;

import java.util.List;
import java.util.Map;
import java.io.File;

import org.apache.log4j.Logger;

import com.smart.ibus.ap.core.boc.BaseBOController;
import com.smart.ibus.ap.designer.impl.PictureUIPersistentServiceImpl;

public class PictureBOController extends BaseBOController{
	
	private Logger logger = Logger.getLogger(PictureBOController.class);
	
    public String loadBackground(Map<String ,Object> pMap) throws Exception {
    	
    	String imgs = "";
		
    	try {
    		String path = this.getClass().getResource(File.separator).getPath();
    		System.out.println("path = ---------------------------------------------" + path);
    		path = path.substring(0, path.lastIndexOf("WEB-INF")-1);
    		//path = path + "/jsp/developcenter/unitdesigner/picture/imgs/background/";
    		path = path + File.separator + "jsp" + File.separator + "developcenter" +
    		       File.separator + "unitdesigner" + File.separator + "picture" + File.separator +
    		       "imgs" + File.separator + "background" + File.separator;
//    		String path = System.getProperty("user.dir");
    		System.out.println("path = ---------------------------------------------" + path);
    		File f=new File(path);
    		File[] fs= f.listFiles();
    		for (int i = 0; i < fs.length; i++) {
    			System.out.println(fs[i].getName());
    			String filetype = fs[i].getName().substring(fs[i].getName().lastIndexOf(".")+1);
    			//System.out.println(filetype);
    			if ("gif,jpg,png,icon,bmp".contains(filetype.toLowerCase())) {
    				if ("".equals(imgs)) {
        				imgs = fs[i].getName();
        			} else {
        				imgs = imgs + "," +fs[i].getName();
        			}
				}	
    		}
		} catch (Exception e) {
			logger.info("加载背景图片信息异常,异常信息为: " + e.getMessage());
		}
	   
		
		
		System.out.println("imgs = ---------------------------------------------" + imgs);
		return imgs;
		
	}
    
    public String loadLogo(Map<String ,Object> pMap) throws Exception {
		String imgs = "";
		try {
			String path = this.getClass().getResource(File.separator).getPath();
			path = path.substring(0, path.lastIndexOf("WEB-INF")-1);
			//path = path + "/jsp/developcenter/unitdesigner/picture/imgs/logo/";
			path = path + File.separator + "jsp" + File.separator + "developcenter" +
		       File.separator + "unitdesigner" + File.separator + "picture" + File.separator +
		       "imgs" + File.separator + "logo" + File.separator;
//			String path = System.getProperty("user.dir");
			System.out.println(path);
			File f=new File(path);
			File[] fs= f.listFiles();
			for (int i = 0; i < fs.length; i++) {
				System.out.println(fs[i].getName());
				String filetype = fs[i].getName().substring(fs[i].getName().lastIndexOf(".")+1);
				//filetype.contains(s)
				if ("gif,jpg,png,icon,bmp".contains(filetype.toLowerCase())) {
    				if ("".equals(imgs)) {
        				imgs = fs[i].getName();
        			} else {
        				imgs = imgs + "," +fs[i].getName();
        			}
				}
				
			}
		} catch (Exception e) {
			logger.info("加载logo图片信息异常,异常信息为: " + e.getMessage());
		}
		
		System.out.println("logoimgs = ---------------------------------------------" + imgs);
		return imgs;
		
	}

}

 
阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭