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

📄 confighelper.java

📁 structs源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        }

        return instance;
    }

    /**
     * <p> Return the form bean definition associated with the specified
     * logical name, if any; otherwise return <code>null</code>. </p>
     *
     * @param name Logical name of the requested form bean definition
     */
    public ActionFormBean getFormBean(String name) {
        return null;
    }

    /**
     * <p> Return the forwarding associated with the specified logical name,
     * if any; otherwise return <code>null</code>. </p>
     *
     * @param name Logical name of the requested forwarding
     */
    public ActionForward getActionForward(String name) {
        return null;
    }

    /**
     * <p> Return the mapping associated with the specified request path, if
     * any; otherwise return <code>null</code>. </p>
     *
     * @param path Request path for which a mapping is requested
     */
    public ActionMapping getActionMapping(String path) {
        return null;
    }

    /**
     * <p> Return the form action converted into an action mapping path.  The
     * value of the <code>action</code> property is manipulated as follows in
     * computing the name of the requested mapping:</p>
     *
     * <ul>
     *
     * <li>Any filename extension is removed (on the theory that extension
     * mapping is being used to select the controller servlet).</li>
     *
     * <li>If the resulting value does not start with a slash, then a slash is
     * prepended.</li>
     *
     * </ul>
     */
    public String getActionMappingName(String action) {
        String value = action;
        int question = action.indexOf("?");

        if (question >= 0) {
            value = value.substring(0, question);
        }

        int slash = value.lastIndexOf("/");
        int period = value.lastIndexOf(".");

        if ((period >= 0) && (period > slash)) {
            value = value.substring(0, period);
        }

        if (value.startsWith("/")) {
            return (value);
        } else {
            return ("/" + value);
        }
    }

    /**
     * <p> Return the form action converted into a server-relative URL. </p>
     */
    public String getActionMappingURL(String action) {
        StringBuffer value = new StringBuffer(this.request.getContextPath());

        // Use our servlet mapping, if one is specified
        String servletMapping = getServletMapping();

        if (servletMapping != null) {
            String queryString = null;
            int question = action.indexOf("?");

            if (question >= 0) {
                queryString = action.substring(question);
            }

            String actionMapping = getActionMappingName(action);

            if (servletMapping.startsWith("*.")) {
                value.append(actionMapping);
                value.append(servletMapping.substring(1));
            } else if (servletMapping.endsWith("/*")) {
                value.append(servletMapping.substring(0,
                        servletMapping.length() - 2));
                value.append(actionMapping);
            }

            if (queryString != null) {
                value.append(queryString);
            }
        }
        // Otherwise, assume extension mapping is in use and extension is
        // already included in the action property
        else {
            if (!action.startsWith("/")) {
                value.append("/");
            }

            value.append(action);
        }

        // Return the completed value
        return (value.toString());
    }

    /**
     * <p> Return the url encoded to maintain the user session, if any. </p>
     */
    public String getEncodeURL(String url) {
        if ((session != null) && (response != null)) {
            boolean redirect = false;

            if (forward != null) {
                redirect = forward.getRedirect();
            }

            if (redirect) {
                return response.encodeRedirectURL(url);
            } else {
                return response.encodeURL(url);
            }
        } else {
            return (url);
        }
    }

    // ------------------------------------------------ Presentation API

    /**
     * <p> Renders the reference for a HTML <base> element </p>
     */
    public String getOrigRef() {
        // HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
        if (request == null) {
            return null;
        }

        StringBuffer result =
            RequestUtils.requestToServerUriStringBuffer(request);

        return result.toString();
    }

    /**
     * <p> Renders the reference for a HTML <base> element. </p>
     */
    public String getBaseRef() {
        if (request == null) {
            return null;
        }

        StringBuffer result = RequestUtils.requestToServerStringBuffer(request);
        String path;

        if (forward == null) {
            path = request.getRequestURI();
        } else {
            path = request.getContextPath() + forward.getPath();
        }

        result.append(path);

        return result.toString();
    }

    /**
     * <p> Return the path for the specified forward, otherwise return
     * <code>null</code>. </p>
     *
     * @param name Name given to local or global forward.
     */
    public String getLink(String name) {
        ActionForward forward = getActionForward(name);

        if (forward == null) {
            return null;
        }

        StringBuffer path = new StringBuffer(this.request.getContextPath());

        path.append(forward.getPath());

        // :TODO: What about runtime parameters?
        return getEncodeURL(path.toString());
    }

    /**
     * <p> Return the localized message for the specified key, otherwise
     * return <code>null</code>. </p>
     *
     * @param key Message key
     */
    public String getMessage(String key) {
        MessageResources resources = getMessageResources();

        if (resources == null) {
            return null;
        }

        return resources.getMessage(RequestUtils.getUserLocale(request, null),
            key);
    }

    /**
     * <p> Look up and return a message string, based on the specified
     * parameters. </p>
     *
     * @param key  Message key to be looked up and returned
     * @param args Replacement parameters for this message
     */
    public String getMessage(String key, Object[] args) {
        MessageResources resources = getMessageResources();

        if (resources == null) {
            return null;
        }

        // Return the requested message
        if (args == null) {
            return resources.getMessage(RequestUtils.getUserLocale(request, null),
                key);
        } else {
            return resources.getMessage(RequestUtils.getUserLocale(request, null),
                key, args);
        }
    }

    /**
     * <p> Return the URL for the specified ActionMapping, otherwise return
     * <code>null</code>. </p>
     *
     * @param path Name given to local or global forward.
     */
    public String getAction(String path) {
        return getEncodeURL(getActionMappingURL(path));
    }

    // --------------------------------------------- Presentation Wrappers

    /**
     * <p> Wrapper for getLink(String) </p>
     *
     * @param name Name given to local or global forward.
     */
    public String link(String name) {
        return getLink(name);
    }

    /**
     * <p> Wrapper for getMessage(String) </p>
     *
     * @param key Message key
     */
    public String message(String key) {
        return getMessage(key);
    }

    /**
     * <p> Wrapper for getMessage(String,Object[]) </p>
     *
     * @param key  Message key to be looked up and returned
     * @param args Replacement parameters for this message
     */
    public String message(String key, Object[] args) {
        return getMessage(key, args);
    }

    /**
     * <p> Wrapper for getAction(String) </p>
     *
     * @param path Name given to local or global forward.
     */
    public String action(String path) {
        return getAction(path);
    }
}

⌨️ 快捷键说明

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