request.getRealPath 过期解决

    xiaoxiao2021-12-14  16

    例子: String fileUrl = request.getSession().getServletContext().getRealPath("/upload")+"/stafftemplate.xls"; request.getRealPath("") 这个方法已经不推荐使用了,那代替它的是什么方法呢? 下面就是替代它的方法: request.getSession().getServletContext().getRealPath() 得到站点的绝对地址 在servlet或者struts中还可以这样: this.getServletContext().getRealPath("/"); this.getServlet().getServletContext().getRealPath("/");
    转载请注明原文地址: https://ju.6miu.com/read-965206.html

    最新回复(0)