zoukankan      html  css  js  c++  java
  • spring设置webAppRootKey

    今天一个同事来问webAppRootKey 在哪设置的

    <context-param>
            <param-name>webAppRootKey</param-name>
            <param-value>xxxxx.root</param-value>
        </context-param>

    spring干的,代码在org.springframework.web.util.WebUtils类的setWebAppRootSystemProperty方法

    代码如下,简单

    public static void setWebAppRootSystemProperty(ServletContext servletContext) throws IllegalStateException {
            Assert.notNull(servletContext, "ServletContext must not be null");
            String root = servletContext.getRealPath("/");
            if (root == null) {
                throw new IllegalStateException(
                    "Cannot set web app root system property when WAR file is not expanded");
            }
            String param = servletContext.getInitParameter(WEB_APP_ROOT_KEY_PARAM);
            String key = (param != null ? param : DEFAULT_WEB_APP_ROOT_KEY);
            String oldValue = System.getProperty(key);
            if (oldValue != null && !StringUtils.pathEquals(oldValue, root)) {
                throw new IllegalStateException(
                    "Web app root system property already set to different value: '" +
                    key + "' = [" + oldValue + "] instead of [" + root + "] - " +
                    "Choose unique values for the 'webAppRootKey' context-param in your web.xml files!");
            }
            System.setProperty(key, root);
            servletContext.log("Set web app root system property: '" + key + "' = [" + root + "]");
        }

    ---EOF--

  • 相关阅读:
    前端 HTML
    python3内置函数
    内置函数的随机验证码
    线程、进程以及协程,上下文管理器
    线程池的定义方法
    python_控制台输出带颜色的文字方法
    while 循环 continue break 用法例子
    JVM 基础知识
    ios 设置状态栏文本颜色为白色
    ios 常用第三方库要加的framework,ARC的设置
  • 原文地址:https://www.cnblogs.com/simoncook/p/5390037.html
Copyright © 2011-2022 走看看