當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。