您的位置:首页 > 其它

得到项目的绝对路径

2011-04-16 23:18 302 查看
今天开发项目中发现:

request.getRealPath(arg0);

报警告:

The method getRealPath(String) from the type ServletRequest is deprecated

request.getRealPath("")

这个方法已经不推荐使用了,那代替它的是什么方法呢?

Deprecated. As of Version 2.1 of the Java Servlet API, use ServletContext.getRealPath(java.lang.String) instead.

[b]request.getSession().getServletContext().getRealPath()


[/b]
[b]得到站点的绝对地址 如:


[/b]



D:/apache-tomcat-6.0.29/webapps/csts_12/

request.getContextPath()则显示: /csts_12

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: