2018.05.15更新:如果可以使用這個方法也是可以的
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
+ path + "/";
String importfile = basePath + "jsp/qt/public_page_top.jsp";
%>
2018.04.12更新:還是建議使用絕對路徑上傳:
詳情請諮詢我的另一篇文章:文件上傳顯示問題:https://blog.csdn.net/qq7758521fang/article/details/79897783
1.打開你的Javaweb項目中的Properties
2.找到Reource:找到Location:“你的路徑”
3.在路徑後添加 String savePath = "“你的路徑”+/WebContent/image/upload";
即可添加到項目中的你想要的路徑中去