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

📄 strutsutility.java

📁 本系统有十分强大的功能
💻 JAVA
字号:
package org.opencustomer.framework.webapp.struts;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.Globals;
import org.apache.struts.taglib.TagUtils;

public final class StrutsUtility {

    private StrutsUtility() {
    }
    
    public static String buildContextPath(HttpServletRequest request, String path) 
    {
        StringBuffer value = new StringBuffer();

        // Use our servlet mapping, if one is specified
        String servletMapping =
                (String) request.getSession().getServletContext().getAttribute(
                        Globals.SERVLET_KEY);

        if (servletMapping != null) {

            String queryString = null;
            int question = path.indexOf("?");
            if (question >= 0) {
                queryString = path.substring(question);
            }

            String actionMapping = TagUtils.getInstance().getActionMappingName(path);
            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);

            } else if (servletMapping.equals("/")) {
                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 (!path.startsWith("/")) {
                value.append("/");
            }
            value.append(path);
        }

        return value.toString();
    }

}

⌨️ 快捷键说明

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