JSP上传文件设置上传文件夹的绝对路径

2025-04-28 03:24:14
推荐回答(2个)
回答1:

  1. <% String path = request.getContextPath();
    //返回形式http://localhost:8080/upload
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";/ >
    2。  调用:
    <%=basePath%>
    在js代码里也可以直接用

回答2:

request.getServletContext().getRealPath() +"/uploader"