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


Java ValueStack.findValue方法代码示例

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


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

示例1: execute

import com.opensymphony.xwork2.util.ValueStack; //导入方法依赖的package包/类
@Override
public void execute(ActionInvocation ai) throws Exception {
    ServletActionContext.getResponse().setContentType("text/plain");
    ServletActionContext.getResponse().setCharacterEncoding("utf-8");
    PrintWriter responseStream = ServletActionContext.getResponse().getWriter();
    ValueStack valueStack = ai.getStack();
    String text = (String) valueStack.findValue("textResult");
    responseStream.print(text);
    responseStream.flush();
}
 
开发者ID:robertli0719,项目名称:ZeroSSH,代码行数:11,代码来源:TextResult.java

示例2: getAttribute

import com.opensymphony.xwork2.util.ValueStack; //导入方法依赖的package包/类
/**
 * Gets the object, looking in the value stack if not found
 *
 * @param key The attribute key
 */
public Object getAttribute(String key) {
    if (key == null) {
        throw new NullPointerException("You must specify a key value");
    }

    if (disableRequestAttributeValueStackLookup || key.startsWith("javax.servlet")) {
        // don't bother with the standard javax.servlet attributes, we can short-circuit this
        // see WW-953 and the forums post linked in that issue for more info
        return super.getAttribute(key);
    }

    ActionContext ctx = ActionContext.getContext();
    Object attribute = super.getAttribute(key);

    if (ctx != null && attribute == null) {
        boolean alreadyIn = isTrue((Boolean) ctx.get(REQUEST_WRAPPER_GET_ATTRIBUTE));

        // note: we don't let # come through or else a request for
        // #attr.foo or #request.foo could cause an endless loop
        if (!alreadyIn && !key.contains("#")) {
            try {
                // If not found, then try the ValueStack
                ctx.put(REQUEST_WRAPPER_GET_ATTRIBUTE, Boolean.TRUE);
                ValueStack stack = ctx.getValueStack();
                if (stack != null) {
                    attribute = stack.findValue(key);
                }
            } finally {
                ctx.put(REQUEST_WRAPPER_GET_ATTRIBUTE, Boolean.FALSE);
            }
        }
    }
    return attribute;
}
 
开发者ID:txazo,项目名称:struts2,代码行数:40,代码来源:StrutsRequestWrapper.java

示例3: resolveParamsFromStack

import com.opensymphony.xwork2.util.ValueStack; //导入方法依赖的package包/类
/**
 * Tries to lookup the parameters on the stack.  Will override any existing parameters
 *
 * @param stack The current value stack
 * @param invocation the action invocation
 */
protected void resolveParamsFromStack(ValueStack stack, ActionInvocation invocation) {
    String disposition = stack.findString("contentDisposition");
    if (disposition != null) {
        setContentDisposition(disposition);
    }

    String contentType = stack.findString("contentType");
    if (contentType != null) {
        setContentType(contentType);
    }

    String inputName = stack.findString("inputName");
    if (inputName != null) {
        setInputName(inputName);
    }

    String contentLength = stack.findString("contentLength");
    if (contentLength != null) {
        setContentLength(contentLength);
    }

    Integer bufferSize = (Integer) stack.findValue("bufferSize", Integer.class);
    if (bufferSize != null) {
        setBufferSize(bufferSize);
    }

    if (contentCharSet != null ) {
        contentCharSet = conditionalParse(contentCharSet, invocation);
    }
    else {
        contentCharSet = stack.findString("contentCharSet");
    }
}
 
开发者ID:txazo,项目名称:struts2,代码行数:40,代码来源:StreamResult.java

示例4: getFormatted

import com.opensymphony.xwork2.util.ValueStack; //导入方法依赖的package包/类
/**
 * Dedicated method to support I10N and conversion errors
 *
 * @param key message which contains formatting string
 * @param expr that should be formatted
 * @return formatted expr with format specified by key
 */
public String getFormatted(String key, String expr) {
    Map<String, Object> conversionErrors = ActionContext.getContext().getConversionErrors();
    if (conversionErrors.containsKey(expr)) {
        String[] vals = (String[]) conversionErrors.get(expr);
        return vals[0];
    } else {
        final ValueStack valueStack = ActionContext.getContext().getValueStack();
        final Object val = valueStack.findValue(expr);
        return getText(key, Arrays.asList(val));
    }
}
 
开发者ID:txazo,项目名称:struts2,代码行数:19,代码来源:ActionSupport.java

示例5: testNullIsNotReturnedWhenCreateNullObjectsIsSpecified

import com.opensymphony.xwork2.util.ValueStack; //导入方法依赖的package包/类
public void testNullIsNotReturnedWhenCreateNullObjectsIsSpecified() {
    ValueStack vs = ActionContext.getContext().getValueStack();
    vs.push(new MapHolder(Collections.emptyMap()));
    ReflectionContextState.setCreatingNullObjects(vs.getContext(), true);

    Object value = vs.findValue("map['key']");
    assertNotNull(value);
    assertSame(Object.class, value.getClass());
}
 
开发者ID:txazo,项目名称:struts2,代码行数:10,代码来源:XWorkMapPropertyAccessorTest.java

示例6: intercept

import com.opensymphony.xwork2.util.ValueStack; //导入方法依赖的package包/类
@Override public String intercept(ActionInvocation invocation) throws Exception {

        ActionConfig config = invocation.getProxy().getConfig();
        ActionContext ac = invocation.getInvocationContext();
        Object action = invocation.getAction();

        // get the action's parameters
        final Map<String, String> parameters = config.getParams();

        if (parameters.containsKey(aliasesKey)) {

            String aliasExpression = parameters.get(aliasesKey);
            ValueStack stack = ac.getValueStack();
            Object obj = stack.findValue(aliasExpression);

            if (obj != null && obj instanceof Map) {
                //get secure stack
                ValueStack newStack = valueStackFactory.createValueStack(stack);
                boolean clearableStack = newStack instanceof ClearableValueStack;
                if (clearableStack) {
                    //if the stack's context can be cleared, do that to prevent OGNL
                    //from having access to objects in the stack, see XW-641
                    ((ClearableValueStack)newStack).clearContextValues();
                    Map<String, Object> context = newStack.getContext();
                    ReflectionContextState.setCreatingNullObjects(context, true);
                    ReflectionContextState.setDenyMethodExecution(context, true);
                    ReflectionContextState.setReportingConversionErrors(context, true);

                    //keep locale from original context
                    context.put(ActionContext.LOCALE, stack.getContext().get(ActionContext.LOCALE));
                }

                // override
                Map aliases = (Map) obj;
                for (Object o : aliases.entrySet()) {
                    Map.Entry entry = (Map.Entry) o;
                    String name = entry.getKey().toString();
                    String alias = (String) entry.getValue();
                    Object value = stack.findValue(name);
                    if (null == value) {
                        // workaround
                        Map<String, Object> contextParameters = ActionContext.getContext().getParameters();

                        if (null != contextParameters) {
                            value = contextParameters.get(name);
                        }
                    }
                    if (null != value) {
                        try {
                            newStack.setValue(alias, value);
                        } catch (RuntimeException e) {
                            if (devMode) {
                                String developerNotification = LocalizedTextUtil.findText(ParametersInterceptor.class, "devmode.notification", ActionContext.getContext().getLocale(), "Developer Notification:\n{0}", new Object[]{
                                        "Unexpected Exception caught setting '" + entry.getKey() + "' on '" + action.getClass() + ": " + e.getMessage()
                                });
                                LOG.error(developerNotification);
                                if (action instanceof ValidationAware) {
                                    ((ValidationAware) action).addActionMessage(developerNotification);
                                }
                            }
                        }
                    }
                }

                if (clearableStack && (stack.getContext() != null) && (newStack.getContext() != null))
                    stack.getContext().put(ActionContext.CONVERSION_ERRORS, newStack.getContext().get(ActionContext.CONVERSION_ERRORS));
            } else {
                LOG.debug("invalid alias expression: {}", aliasesKey);
            }
        }
        
        return invocation.invoke();
    }
 
开发者ID:txazo,项目名称:struts2,代码行数:74,代码来源:AliasInterceptor.java


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