当前位置: 首页>>代码示例>>Java>>正文


Java ActionContext.getParameters方法代码示例

本文整理汇总了Java中com.opensymphony.xwork2.ActionContext.getParameters方法的典型用法代码示例。如果您正苦于以下问题:Java ActionContext.getParameters方法的具体用法?Java ActionContext.getParameters怎么用?Java ActionContext.getParameters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.opensymphony.xwork2.ActionContext的用法示例。


在下文中一共展示了ActionContext.getParameters方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addParametersToContext

import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
/**
 * Adds the parameters into context's ParameterMap.
 * As default, static parameters will not overwrite existing paramaters from other sources.
 * If you want the static parameters as successor over already existing parameters, set overwrite to <tt>true</tt>.
 *
 * @param ac        The action context
 * @param newParams The parameter map to apply
 */
protected void addParametersToContext(ActionContext ac, Map<String, ?> newParams) {
    Map<String, Object> previousParams = ac.getParameters();

    Map<String, Object> combinedParams;
    if ( overwrite ) {
        if (previousParams != null) {
            combinedParams = new TreeMap<>(previousParams);
        } else {
            combinedParams = new TreeMap<>();
        }
        if ( newParams != null) {
            combinedParams.putAll(newParams);
        }
    } else {
        if (newParams != null) {
            combinedParams = new TreeMap<>(newParams);
        } else {
            combinedParams = new TreeMap<>();
        }
        if ( previousParams != null) {
            combinedParams.putAll(previousParams);
        }
    }
    ac.setParameters(combinedParams);
}
 
开发者ID:txazo,项目名称:struts2,代码行数:34,代码来源:StaticParametersInterceptor.java

示例2: handleInvalidToken

import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
@Override
 protected String handleInvalidToken(ActionInvocation invocation) throws Exception {
     ActionContext ac = invocation.getInvocationContext();

     HttpServletRequest request = (HttpServletRequest) ac.get(ServletActionContext.HTTP_REQUEST);
     HttpServletResponse response = (HttpServletResponse) ac.get(ServletActionContext.HTTP_RESPONSE);
     String tokenName = TokenHelper.getTokenName();
     String token = TokenHelper.getToken(tokenName);

     if ((tokenName != null) && (token != null)) {
         Map params = ac.getParameters();
         params.remove(tokenName);
         params.remove(TokenHelper.TOKEN_NAME_FIELD);

String sessionTokenName = TokenHelper.buildTokenSessionAttributeName(tokenName);
         ActionInvocation savedInvocation = InvocationSessionStore.loadInvocation(sessionTokenName, token);

         if (savedInvocation != null) {
             // set the valuestack to the request scope
             ValueStack stack = savedInvocation.getStack();
             request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, stack);

             ActionContext savedContext = savedInvocation.getInvocationContext();
             savedContext.getContextMap().put(ServletActionContext.HTTP_REQUEST, request);
             savedContext.getContextMap().put(ServletActionContext.HTTP_RESPONSE, response);
             Result result = savedInvocation.getResult();

             if ((result != null) && (savedInvocation.getProxy().getExecuteResult())) {
                 result.execute(savedInvocation);
             }

             // turn off execution of this invocations result
             invocation.getProxy().setExecuteResult(false);

             return savedInvocation.getResultCode();
         }
     }

     return INVALID_TOKEN_CODE;
 }
 
开发者ID:txazo,项目名称:struts2,代码行数:41,代码来源:TokenSessionStoreInterceptor.java

示例3: addParametersToContext

import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
/**
 * Adds the parameters into context's ParameterMap
 *
 * @param ac        The action context
 * @param newParams The parameter map to apply
 *                  <p>
 *                  In this class this is a no-op, since the parameters were fetched from the same location.
 *                  In subclasses both retrieveParameters() and addParametersToContext() should be overridden.
 *                  </p>
 */
@Override
protected void addParametersToContext(ActionContext ac, Map newParams) {
    Map previousParams = ac.getParameters();
    Map combinedParams;
    if (previousParams != null) {
        combinedParams = new TreeMap(previousParams);
    } else {
        combinedParams = new TreeMap();
    }
    combinedParams.putAll(newParams);

    ac.setParameters(combinedParams);
}
 
开发者ID:txazo,项目名称:struts2,代码行数:24,代码来源:ActionMappingParametersInteceptor.java

示例4: intercept

import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
/**
 * Decide if the parameter should be removed from the parameter map based on
 * <code>paramNames</code> and <code>paramValues</code>.
 * 
 * @see com.opensymphony.xwork2.interceptor.AbstractInterceptor
 */
@Override
public String intercept(ActionInvocation invocation) throws Exception {
	if (!(invocation.getAction() instanceof NoParameters)
			&& (null != this.paramNames)) {
		ActionContext ac = invocation.getInvocationContext();
		final Map<String, Object> parameters = ac.getParameters();

		if (parameters != null) {
               for (String removeName : paramNames) {
                   // see if the field is in the parameter map
                   if (parameters.containsKey(removeName)) {

                       try {
						String[] values = (String[]) parameters.get(removeName);
						String value = values[0];
						if (null != value && this.paramValues.contains(value)) {
                               parameters.remove(removeName);
                           }
                       } catch (Exception e) {
						LOG.error("Failed to convert parameter to string", e);
					}
				}
               }
		}
	}
	return invocation.invoke();
}
 
开发者ID:txazo,项目名称:struts2,代码行数:34,代码来源:ParameterRemoverInterceptor.java

示例5: retrieveParameters

import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
/**
 * Gets the parameter map to apply from wherever appropriate
 *
 * @param ac The action context
 * @return The parameter map to apply
 */
protected Map<String, Object> retrieveParameters(ActionContext ac) {
    return ac.getParameters();
}
 
开发者ID:txazo,项目名称:struts2,代码行数:10,代码来源:ParametersInterceptor.java


注:本文中的com.opensymphony.xwork2.ActionContext.getParameters方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。