⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mywebapplicationcontextutils.java

📁 学习tapestry的好书啊,绝对经典实用.
💻 JAVA
字号:
package com.cucu.tapestry.springframework;

import org.springframework.web.context.support.WebApplicationContextUtils;
import org.springframework.web.context.WebApplicationContext;
import org.apache.tapestry.web.WebContext;

/**
 * @author 绝情酷哥
 * @version $Id$
 */
public class MyWebApplicationContextUtils extends WebApplicationContextUtils {

    public static WebApplicationContext getWebApplicationContext(WebContext wc) {
        Object obj = wc.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
        if (obj == null) {
            return null;
        }
        if (obj instanceof RuntimeException) {
            throw (RuntimeException) obj;
        }
        if (obj instanceof Error) {
            throw (Error) obj;
        }
        if (!(obj instanceof WebApplicationContext)) {
            throw new IllegalStateException("Root context attribute is not of type WebApplicationContext: " + obj);
        }
        return (WebApplicationContext) obj;
    }

    public static WebApplicationContext getRequiredWebApplicationContext(WebContext wc) {
        WebApplicationContext wac = getWebApplicationContext(wc);
        if (wac == null) {
            throw new IllegalStateException("No WebApplicationContext found: no ContextLoaderListener registered?");
        }
        return wac;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -