首页 > Web开发 > 详细

JSP---jsp页面获取物理路径

时间:2014-07-17 18:10:12      阅读:305      评论:0      收藏:0      [点我收藏+]

(非原创)

在jsp页面中使用request.getRealPath("/")时出现下列警告:

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

出现该警告,该方法已经不能使用了

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

可以使用下面的方法来替代上面的方法

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

在servlet或者struts中还可以这样:

this.getServletContext().getRealPath("/");

this.getServlet().getServletContext().getRealPath("/");

JSP---jsp页面获取物理路径,布布扣,bubuko.com

JSP---jsp页面获取物理路径

原文:http://www.cnblogs.com/beast-king/p/3851164.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!