日期:2014-05-18  浏览次数:20838 次

求JSP中request.getRealPath()和application.getRealPath()的详尽用法
JSP中request.getRealPath()和application.getRealPath()的详细用法?

------解决方案--------------------
没啥用法啊!都是获得你的WEB程序所在的物理路径,但request.getRealPath( " ")是个过时的方法,SUN公司的Servlet API 1.3就不建议使用了!
我一般使用request.getSession().getRealPath( " ")方法获取绝对路径!
------解决方案--------------------
request.getRealPath()在tomcat.apache.org的servlet API中说已经过时,建议使用
ServletContext.getRealPath(java.lang.String) 代替
如果你打开TOMCAT下的WORK目录,会有很大的收获的.
仔细看那些JAVA文件,其实就是你的JSP编译产生的,看一下会更了解JSP的,最好有servlet的基础
------解决方案--------------------
public ActionForward execute(ActionMapping mapping, 
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
........
String dir = request.getSession().getServletContext.getRealPath("...");
.......
}