随笔-7  评论-24  文章-102  trackbacks-0

如果地址为 http://localhost:8080/deviantART/test/MyJsp.jsp


request.getContextPath()                    /deviantART 
    获得容器上下文路径,一般为网站的相对路径(项目名)。如果为根目录,则返回值为 ""。

request.getServletPath()                    /test/MyJsp.jsp
    获得 Servlet 相对路径。

request.getRequestURI()                  /deviantART/test/MyJsp.jsp 
    获得请求路径。

request.getRealPath("")                                D:\Program Files\apache-tomcat-6.0.16\webapps\deviantART
request.getRealPath("/AAAA/BBBB")          D:\Program Files\apache-tomcat-6.0.16\webapps\deviantART\AAAA\BBBB 
    获得绝对路径(不推荐使用)。

########################################################


application.getContextPath()                        /deviantART

application.getRealPath("")                          D:\Program Files\apache-tomcat-6.0.16\webapps\deviantART
application.getRealPath("AA/BB")               D:\Program Files\apache-tomcat-6.0.16\webapps\deviantART\AA\BB

application.getRealPath(request.getServletPath())
                                        D:\Program Files\apache-tomcat-6.0.16\webapps\deviantART\test\MyJsp.jsp


##########################################################
replaceAll("\\\\","xxxx");                     表示一个"\"





posted on 2008-09-05 15:44 黄小二 阅读(242) 评论(0)  编辑  收藏 所属分类: J2EE

只有注册用户登录后才能发表评论。


网站导航: