/**
* Return the real path of the given path within the web application,
* as provided by the portlet container.
* <p>Prepends a slash if the path does not already start with a slash,
* and throws a {@link java.io.FileNotFoundException} if the path cannot
* be resolved to a resource (in contrast to
* {@link javax.portlet.PortletContext#getRealPath PortletContext's {@code getRealPath}},
* which simply returns {@code null}).
* @param portletContext the portlet context of the web application
* @param path the relative path within the web application
* @return the corresponding real path
* @throws FileNotFoundException if the path cannot be resolved to a resource
* @see javax.portlet.PortletContext#getRealPath
*/
public static String getRealPath(PortletContext portletContext, String path) throws FileNotFoundException {
Assert.notNull(portletContext, "PortletContext must not be null");
// Interpret location as relative to the web application root directory.
if (!path.startsWith("/")) {
path = "/" + path;
}
String realPath = portletContext.getRealPath(path);
if (realPath == null) {
throw new FileNotFoundException(
"PortletContext resource [" + path + "] cannot be resolved to absolute file path - " +
"web application archive not expanded?");
}
return realPath;
}
PortletUtils.java 文件源码
java
阅读 23
收藏 0
点赞 0
评论 0
项目:spring4-understanding
作者:
评论列表
文章目录