EOSjava获取应用上下文 (获取路径)

取应用上下文单例
ApplicationContext context = ApplicationContext.getInstance();
获取应用名称 context.getAppName();
获取应用工作路径 context.getApplicationWorkPath();
获取Home路径 context.getEOS_HOME();
获取应用配置文件夹路径(系统、用户) context.getApplicationConfigPath();
获取应用系统相关构件存储库路径 context.getApplicationSystemWorkingPath();
获取应用用户相关构件存储库路径 context.getApplicationUserWorkingPath();
获取应用EAR所在物理目录 context.getEarRealPath();
获取WAR所在目录 context.getWarRealPath();

例如
//模板路径
String modelPath = ApplicationContext.getInstance().getWarRealPath()+“upload”+File.separator+“temp”+File.separator+“tzd_zqcgfp.docx”;

//获取在web.xml中配置的路径
	    public static String getFileDir(String processinstid){
	    	String url = "";
	    	int dateTime =Integer.parseInt(getDateTime()) ;
	    	String rtn = getTimeRtn(processinstid);
	    	int intRtn = Integer.parseInt(rtn);
			if(intRtn <= dateTime){
			rtn = dateTime+"";
			}
	    	try{
	    		String xmlUrl = ApplicationContext.getInstance().getWarRealPath() + "WEB-INF/web.xml";
	    		DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
				DocumentBuilder db = dbf.newDocumentBuilder();
				Document doc = db.parse(new File(xmlUrl));
				NodeList list = doc.getElementsByTagName("context-param");
				for(int i=0;i<list.getLength();i++){
					Element element = (Element) list.item(i);
					String name = element.getElementsByTagName("param-name").item(0).getFirstChild().getNodeValue();
					if(name.equals("letterFileDir")){
						url = element.getElementsByTagName("param-value").item(0).getFirstChild().getNodeValue();
						break;
					}
				}
	    	}catch(Exception e){
	    		e.printStackTrace();
	    	}
	    	String fileDir = url+File.separator+rtn;	
	        File tempDirPath =new File(fileDir);
	        if(!tempDirPath.exists()){ 
	            tempDirPath.mkdirs();  
	        } 
	    	return fileDir;
	    }
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值