设为首页收藏本站
开启辅助访问
切换到宽版

创星网络[分享知识 传递快乐]

 找回密码
 立即注册

QQ登录

只需一步,快速开始

用新浪微博登录

只需一步,快速搞定

搜索
查看: 3564|回复: 0
打印 上一主题 下一主题

解决weblogic中的getRealPath()问题

[复制链接]

我玩的应用:

跳转到指定楼层
楼主
发表于 2012-12-13 19:50:30 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
getServletContext().getResourceAsStream.示例如下:
     InputStream is = getServletContext().getResourceAsStream(\"/WEB-INF/config.properties\");
      Properties props = new Properties();
           try {
              props.load(is);
          } catch (IOException e) {
              System.err.println(\"Load  configuration failed\");
            }
    PropertyConfigurator.configure(props);
  上面方法并没有解决根本问题,根本问题就是得到RealPath,可以使用下面方法得到RealPath:
           try {
             URL   u = getServletContext().getResource(\"/\");
            String  weblogic_path=u.getPath();
            } catch (MalformedURLException e) {
             e.printStackTrace();
             }
    这个语句得到的RealPath可能不是最终的答案(一般来说前面多了一个/),需要你根据实际情况去加工一下。
    至此问题全部解决。

from:http://blog.csdn.net/luinstein/article/details/5451371
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 转播转播 分享分享 分享淘帖
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|创星网络 ( 苏ICP备11027519号|网站地图  

GMT+8, 2024-5-17 12:50 , Processed in 0.082350 second(s), 26 queries .

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表