一个项目中调用另外一个项目中下载文件的servlet来下载本项目中的资源

xiaoxiao2026-03-18  7

int s = context.getRealPath("/").lastIndexOf("web_upload");String downloadpath = context.getRealPath("/").substring(0, s)+"ptop"+File.separator+"xiazai" + File.separator;System.out.println(downloadpath);

或者

int s = context.getRealPath("").lastIndexOf("\\");//获取上一级目录String downloadpath = context.getRealPath("").substring(0, s)+File.separator+"ptop"+File.separator+"xiazai" + File.separator;

下载 <a href="../web_upload/servlet/down?downFile=2.rar">下载</a>

转载请注明原文地址: https://www.6miu.com/read-5046085.html

最新回复(0)