您的位置:首页 > 运维架构 > Linux

vmstat - Linux系统性能监控工具

2014-07-04 13:54 447 查看
weblogic获取路径总是为NULL

通常情况下载tomcat中
我们以前使用 HttpServletRequest request; request.getRealPath(arg0);
但是这是个过时的方法

request.getSession().getServletContext().getRealPath() 得到站点的绝对地址

HttpServletRequest request;
request.getSession().getServletContext().getRealPath(arg0);

在strut中通过
this.getServlet().getServletContext().getRealPath(arg0);
ServletActionContext.getServletContext().getRealPath(agr0)

在Servlet中通过 extends HttpServlet
this.getServletContext().getRealPath(arg0);

如果 weblogic里面war项目获取路径为空
对一个打包的应用来说,是没有RealPath的概念的,调用getRealPath只会简单地返回null
那么可以推荐尝试
String path=this.getClass().getClassLoader().getResource("/").getPath();
上面这个是获取了web-inf/classes里面的路径,

也可以使用ServletContext.getResourceAsStream("/WEB-INF/config/db.config")方法。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: