---
title: "getRealPath方法为何返回的是null"
author: "ultrang"
date: "2015-09-29T08:59:27Z"
tags: []
categories: ["编程语言"]
slug: "getrealpath-null"
draft: false
lastmod: "2015-09-29T08:59:27Z"
id: 2246643
url: "https://ultrang.iteye.com/blog/2246643"
---

在WebLogic 11的weblogic.xml中可以自定义show-archived-real-path-enabled参数的值，用于使request.getSession().getServletContext().getRealPath("")方法在返回实际路径。
```java
<container-descriptor>
        <show-archived-real-path-enabled>true</show-archived-real-path-enabled>
    </container-descriptor>
```


此参数对于打包的（归档的）web应用程序生效，当设置为true时，getRealPath()返回资源对应的实际路径。否则返回null。