当前位置: 首页>>代码示例>>Java>>正文


Java WebUtils.getRealPath方法代码示例

本文整理汇总了Java中org.springframework.web.util.WebUtils.getRealPath方法的典型用法代码示例。如果您正苦于以下问题:Java WebUtils.getRealPath方法的具体用法?Java WebUtils.getRealPath怎么用?Java WebUtils.getRealPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.web.util.WebUtils的用法示例。


在下文中一共展示了WebUtils.getRealPath方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFile

import org.springframework.web.util.WebUtils; //导入方法依赖的package包/类
/**
 * This implementation resolves "file:" URLs or alternatively delegates to
 * {@code ServletContext.getRealPath}, throwing a FileNotFoundException
 * if not found or not resolvable.
 * @see javax.servlet.ServletContext#getResource(String)
 * @see javax.servlet.ServletContext#getRealPath(String)
 */
@Override
public File getFile() throws IOException {
	URL url = this.servletContext.getResource(this.path);
	if (url != null && ResourceUtils.isFileURL(url)) {
		// Proceed with file system resolution...
		return super.getFile();
	}
	else {
		String realPath = WebUtils.getRealPath(this.servletContext, this.path);
		return new File(realPath);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:ServletContextResource.java

示例2: getRootPath

import org.springframework.web.util.WebUtils; //导入方法依赖的package包/类
public static String getRootPath(String resource) {
	HttpServletRequest request =ThreadContextHolder.getHttpRequest() ;
	try {
		 
		return WebUtils.getRealPath(request.getSession().getServletContext(), resource);
	} catch (FileNotFoundException e) {
		 
		e.printStackTrace();
		return "";
	}
	 
}
 
开发者ID:yulele166,项目名称:pub-service,代码行数:13,代码来源:StringUtil.java

示例3: initLogging

import org.springframework.web.util.WebUtils; //导入方法依赖的package包/类
/**
 * Initialize logback, including setting the web app root system property.
 *
 * @param servletContext the current ServletContext
 * @see WebUtils#setWebAppRootSystemProperty
 */
public static void initLogging(ServletContext servletContext) {
    // Expose the web app root system property.
    if (exposeWebAppRoot(servletContext)) {
        WebUtils.setWebAppRootSystemProperty(servletContext);
    }

    // Only perform custom logback initialization in case of a config file.
    String location = servletContext
            .getInitParameter(CONFIG_LOCATION_PARAM);
    if (location != null) {
        // Perform actual logback initialization; else rely on logback's
        // default initialization.
        try {
            // Return a URL (e.g. "classpath:" or "file:") as-is;
            // consider a plain file path as relative to the web application
            // root directory.
            if (!ResourceUtils.isUrl(location)) {
                // Resolve system property placeholders before resolving
                // real path.
                location = SystemPropertyUtils
                        .resolvePlaceholders(location);
                location = WebUtils.getRealPath(servletContext, location);
            }

            // Write log message to server log.
            servletContext.log("Initializing logback from [" + location
                    + "]");

            // Initialize without refresh check, i.e. without logback's
            // watchdog thread.
            LogbackConfigurer.initLogging(location);

        } catch (FileNotFoundException ex) {
            throw new IllegalArgumentException(
                    "Invalid 'logbackConfigLocation' parameter: "
                            + ex.getMessage());
        }
    }
}
 
开发者ID:glameyzhou,项目名称:scaffold,代码行数:46,代码来源:LogbackWebConfigurer.java

示例4: getFilePath

import org.springframework.web.util.WebUtils; //导入方法依赖的package包/类
private String getFilePath(String dir) throws FileNotFoundException {
    return WebUtils.getRealPath(servletContext, dir);
}
 
开发者ID:lysu,项目名称:diamond,代码行数:4,代码来源:DiskService.java


注:本文中的org.springframework.web.util.WebUtils.getRealPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。