足球游戏_中国足彩网¥体育资讯$

jsp中获取当前目录的方法
来源:易贤网 阅读:884 次 日期:2016-07-01 08:59:00
温馨提示:易贤网小编为您整理了“jsp中获取当前目录的方法”,方便广大网友查阅!

本文实例讲述了jsp中获取当前目录的实现方法,分享给大家供大家参考。具体实现方法如下:

1、利用system.getproperty()函数获取当前路径:

代码如下:

system.out.println(system.getproperty(user.dir));//user.dir指定了当前的路径

2、使用file提供的函数获取当前路径:

代码如下:

file directory = new file();//设定为当前文件夹

try{

system.out.println(directory.getcanonicalpath());//获取标准的路径

system.out.println(directory.getabsolutepath());//获取绝对路径

}catch(exceptin e){}

file.getcanonicalpath()和file.getabsolutepath()大约只是对于new file(.)和new file(..)两种路径有所区别。

# 对于getcanonicalpath()函数,“.就表示当前的文件夹,而”..“则表示当前文件夹的上一级文件夹

# 对于getabsolutepath()函数,则不管”.”、“..”,返回当前的路径加上你在new file()时设定的路径

# 至于getpath()函数,得到的只是你在new file()时设定的路径

比如当前的路径为 c:test :

代码如下:

file directory = new file(abc);

directory.getcanonicalpath(); //得到的是c:testabc

directory.getabsolutepath(); //得到的是c:testabc

direcotry.getpath(); //得到的是abc

file directory = new file(.);

directory.getcanonicalpath(); //得到的是c:test

directory.getabsolutepath(); //得到的是c:test.

direcotry.getpath(); //得到的是.

file directory = new file(..);

directory.getcanonicalpath(); //得到的是c:

directory.getabsolutepath(); //得到的是c:test..

direcotry.getpath(); //得到的是..

获取 java 程序当前的工作目录

代码如下:

file file = new file(t.tmp);

string fullpath = file.getabsolutepath();

① request.getrealpath:

方法:request.getrealpath(/)

得到的路径:c:program filesapache software foundationtomcat 5.5webappsstrutstest

方法:request.getrealpath(.)

得到的路径:c:program filesapache software foundationtomcat 5.5webappsstrutstest.

方法:request.getrealpath()

得到的路径:c:program filesapache software foundationtomcat 5.5webappsstrutstest

方法:request.getrealpath(web.xml)

得到的路径:c:program filesapache software foundationtomcat 5.5webappsstrutstestweb.xml

② request.getparameter();

actionform.getmyfile();

方法:string filepath = request.getparameter(myfile);

得到的路径:d:vss安装目录users.txt

方法:string filepath = actionform.getmyfile();

得到的路径:d:vss安装目录users.txt

希望本文所述对大家的jsp程序设计有所帮助。

中国足彩网信息请查看网页制作
易贤网手机网站地址:jsp中获取当前目录的方法
由于各方面情况的不断调整与变化,易贤网提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!
关于我们 | 联系我们 | 人才招聘 | 网站声明 | 网站帮助 | 非正式的简要咨询 | 简要咨询须知 | 加入群交流 | 手机站点 | 投诉建议
工业和信息化部备案号:滇ICP备2023014141号-1 足球游戏_中国足彩网¥体育资讯$ 滇公网安备53010202001879号 人力资源服务许可证:(云)人服证字(2023)第0102001523号
云南网警备案专用图标
联系电话:0871-65317125(9:00—18:00) 获取招聘考试信息及咨询关注公众号:hfpxwx
咨询QQ:526150442(9:00—18:00)版权所有:易贤网
云南网警报警专用图标