符号怎么打-越狱教程

getrealpath
2023年4月4日发(作者:幸福宝向日葵下载安装地址)

Java实现将图⽚上传到webapp路径下路径获取⽅式

⽬录

将图⽚上传到webapp路径下路径获取⽅式

springjava获取webapp下⽂件路径

将图⽚上传到webapp路径下路径获取⽅式

此⽅法获取到⼯程webapp⽂件夹下

StringcontexPath=sion().getServletContext().getRealPath("/");

获取IP地址端⼝号以及项⽬名称

<%

Stringpath=textPath();

StringbasePath=eme()+"://"+verName()+":"+verPort()+path+"/";

%>

springjava获取webapp下⽂件路径

@RequestMapping("/act/worldcup_schedule_time/imgdownload")

@ResponseBody

publicStringscheduleDownload(HttpServletRequestrequest,HttpServletResponseresponse,HttpSessionsession){

racterEncoding("UTF-8");

StringdownLoadName="";

InputStreaminput=null;

try{

racterEncoding("UTF-8");

//获取⽂件的路径

//Stringurl=vletContext().getRealPath("/")+"resourcesimagesactworldcup_";

Stringurl=vletContext().getRealPath("/")+"resources/images/act/worldcup_merge/";

n(url);

Filefile=newFile(url);

input=putStream(file);

byte[]data=Array(input);

//n("⽂件名:"+downLoadName);

();

//设置响应的报头信息(中⽂问题解决办法)

der("content-disposition","attachment;fileName="+(downLoadName,"UTF-8"));

der("Content-Length",""+);

tentType("image/png;charset=UTF-8");

(data,putStream());

}catch(Exceptione){

("下载图⽚出错");

if(input!=null){

uietly(input);

}

}

returnnull;

}

以上为个⼈经验,希望能给⼤家⼀个参考,也希望⼤家多多⽀持。

更多推荐

getrealpath