我在用户尝试上传csv文件时无法获取文件夹的文件路径。目前,我已经对文件路径进行了硬编码,以便它只从该目录中获取csv文件。我需要获取文件所在的当前文件路径,以便在将文件传输到另一个文件夹时,servlet仍然可以读取我的csv文件的内容。
这是我的代码:
delimiter $$
drop procedure if exists run_queries$$
create procedure run_queries()
begin
declare s_query varchar(255);
declare done bool default false;
declare c_queries cursor for
select REPORT_QUERY from CT;
declare continue handler for not found set done = true;
open c_queries;
read_loop: loop
fetch c_queries into s_query;
if done then
leave read_loop;
end if;
-- run the query
set @sql = s_query;
prepare stmt from @sql;
execute stmt;
deallocate prepare stmt;
end loop;
end$$
我希望String file = request.getParameter("csvFile");
PrintWriter out = response.getWriter();
String fileurl = "/home/user/" + file;
获取csv文件所在的当前文件路径。提前致谢。