webLogic javaweb 路径问题 Not allowed to load local resource

  • 现象描述,在tomcat环境下,可以使用:String path = request.getSession().getServletContext().getRealPath("/")+"zjfxjk\\expertsLib\\photos\\"; 获取服务器地址,并做文件操作。但是在weblogic环境下String path = request.getSession().getServletContext().getRealPath("/")这是一个null值,然后关于文件上传的操作后台报空指针异常
  • 然后尝试使用String path = System.getProperty("user.dir").replace("\\", "/")+"/photos/"; 获取磁盘路径,但是chrome在jsp中使用src粘贴这个地址时,前台报错 “Not allowed to load local resource”
  • 继续修改,String path = new File(this.getClass().getClassLoader().getResource("/").getPath()).getParentFile().getParentFile().getAbsolutePath()+"/zjfxjk/expertsLib/photos/";,后台的地址修改后一切正常
posted @ 2018-01-03 16:16  zhangjieatbky  阅读(461)  评论(0编辑  收藏  举报