servlet中获得路径

以下是HandleUpload这个servlet中输出的结果,该文件属于FileSystem这个app


System.out.println("1. request.getContextPath()="+request.getContextPath());
System.out.println("2. request.getLocalAddr()	="+request.getLocalAddr());
System.out.println("3. request.getRequestURL()	="+request.getRequestURL());
System.out.println("4. request.getRequestURI()	="+request.getRequestURI());
System.out.println("5. request.getServletPath()="+request.getServletPath());
System.out.println("6. request.getRealPath('') ="+request.getRealPath(""));
System.out.println("7. System.getProperty('user.dir')="+System.getProperty("user.dir"));
System.out.println("8. getServletContext().getContextPath()="+getServletContext().getContextPath());
System.out.println("9. getServletContext().getRealPath('/')="+getServletContext().getRealPath("/"));
System.out.println("10.getClass().getClassLoader().getResource('/').getPath()="+getClass().getClassLoader().getResource("/").getPath());


1. request.getContextPath()=/FileSystem
2. request.getLocalAddr()       =192.168.253.1
3. request.getRequestURL()      =http://192.168.253.1:8080/FileSystem/HandleUpload
4. request.getRequestURI()      =/FileSystem/HandleUpload
5. request.getServletPath()=/HandleUpload
6. request.getRealPath('') =null
7. System.getProperty('user.dir')=D:\Program Files\tomcat-8.0.0\bin
8. getServletContext().getContextPath()=/FileSystem
9. getServletContext().getRealPath('/')=D:\Program Files\tomcat-8.0.0\webapps\FileSystem
10.getClass().getClassLoader().getResource('/').getPath()=/D:/Program%20Files/tomcat-8.0.0/webapps/FileSystem/WEB-INF/classes/



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值