src/org/nutz/mvc/view/AbstractPathView.java
public static Context createContext(HttpServletRequest req, Object obj) {
        Context context = Lang.context();
        // 复制全局的上下文对象
        Object globalContext = Mvcs.getServletContext()
                                   .getAttribute(Loading.CONTEXT_NAME);
        if (globalContext != null) {
            context.putAll((Context) globalContext);
        }

        // 请求对象的属性列表
        Map<String, Object> req_attr = new HashMap<String, Object>();
        for (Enumeration<String> en = req.getAttributeNames(); en.hasMoreElements();) {
            String tem = en.nextElement();
            if (!tem.startsWith("$"))
                req_attr.put(tem, req.getAttribute(tem));
        }
        context.set("a", req_attr);// 兼容最初的写法
        context.set("req_attr", req_attr);

        ActionContext ac = Mvcs.getActionContext();
        if (ac != null)
            context.set("pathargs", Mvcs.getActionContext().getPathArgs());

        try {
            HttpSession session = Mvcs.getHttpSession(false);
            if (session != null) {
                Map<String, Object> session_attr = new HashMap<String, Object>();
                for (Enumeration<String> en = session.getAttributeNames(); en.hasMoreElements();) {
                    String tem = en.nextElement();
                    session_attr.put(tem, session.getAttribute(tem));
                }
                context.set("session_attr", session_attr);
            }
        }
        catch (Throwable e) {
            // noop
        }
        // 请求的参数表,需要兼容之前的p.参数, Fix issue 418
        Map<String, String> p = new HashMap<String, String>();
        for (Object o : Lang.enum2collection(req.getParameterNames(), new ArrayList<String>())) {
            String key = (String) o;
            String value = req.getParameter(key);
            p.put(key, value);
            context.set(key, value);// 以支持直接获取请求参数
        }
        context.set("p", p);

        Map<String, String> u = new HashMap<String, String>();
        AtMap at = Mvcs.getAtMap();
        if (at != null) {
            for (Object o : at.keys()) {
                String key = (String) o;
                u.put(key, at.get(key));
            }
            context.set("u", u);
        }

        // 加入返回对象
        if (null != obj)
            context.set(ViewProcessor.DEFAULT_ATTRIBUTE, obj);
        return context;
    }
public static Context createContext(HttpServletRequest req, Object obj) {
        Context context = Lang.context();
        // 复制全局的上下文对象
        Object globalContext = Mvcs.getServletContext()
                                   .getAttribute(Loading.CONTEXT_NAME);
        if (globalContext != null) {
            context.putAll((Context) globalContext);
        }

        // 请求对象的属性列表
        Map<String, Object> req_attr = new HashMap<String, Object>();
        for (Enumeration<String> en = req.getAttributeNames(); en.hasMoreElements();) {
            String tem = en.nextElement();
            if (!tem.startsWith("$"))
                req_attr.put(tem, req.getAttribute(tem));
        }
        context.set("a", req_attr);// 兼容最初的写法
        context.set("req_attr", req_attr);

        ActionContext ac = Mvcs.getActionContext();
        if (ac != null)
            context.set("pathargs", Mvcs.getActionContext().getPathArgs());

        try {
            HttpSession session = Mvcs.getHttpSession(false);
            if (session != null) {
                Map<String, Object> session_attr = new HashMap<String, Object>();
                for (Enumeration<String> en = session.getAttributeNames(); en.hasMoreElements();) {
                    String tem = en.nextElement();
                    session_attr.put(tem, session.getAttribute(tem));
                }
                context.set("session_attr", session_attr);
            }
        }
        catch (Throwable e) {
            // noop
        }
        // 请求的参数表,需要兼容之前的p.参数, Fix issue 418
        Map<String, String> p = new HashMap<String, String>();
        for (Object o : Lang.enum2collection(req.getParameterNames(), new ArrayList<String>())) {
            String key = (String) o;
            String value = req.getParameter(key);
            p.put(key, value);
            context.set(key, value);// 以支持直接获取请求参数
        }
        context.set("p", p);

        Map<String, String> u = new HashMap<String, String>();
        AtMap at = Mvcs.getAtMap();
        if (at != null) {
            for (Object o : at.keys()) {
                String key = (String) o;
                u.put(key, at.get(key));
            }
            context.set("u", u);
        }

        // 加入返回对象
        if (null != obj)
            context.set(ViewProcessor.DEFAULT_ATTRIBUTE, obj);
        return context;
    }
为一次 HTTP 请求，创建一个可以被表达式引擎接受的上下文对象

@param req
HTTP 请求对象
@param obj
入口函数的返回值
@return 上下文对象