當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。