大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。
Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
ActionContext.getContext()返回的是一个ActionContext对象,get(String key)也是ActionContext里面的一个方法。
xwork源码贴出来了:
public class ActionContext implements Serializable {
static ThreadLocal actionContext = new ThreadLocal();
//public static final String DEV_MODE = “__devMode”;
public static final String ACTION_NAME = “com.opensymphony.xwork2.ActionContext.name”;
public static final String VALUE_STACK = ValueStack.VALUE_STACK;
public static final String SESSION = “com.opensymphony.xwork2.ActionContext.session”;
public static final String APPLICATION = “com.opensymphony.xwork2.ActionContext.application”;
public static final String PARAMETERS = “com.opensymphony.xwork2.ActionContext.parameters”;
public static final String LOCALE = “com.opensymphony.xwork2.ActionContext.locale”;
public static final String TYPE_CONVERTER = “com.opensymphony.xwork2.ActionContext.typeConverter”;
public static final String ACTION_INVOCATION = “com.opensymphony.xwork2.ActionContext.actionInvocation”;
public static final String CONVERSION_ERRORS = “com.opensymphony.xwork2.ActionContext.conversionErrors”;
public static final String CONTAINER = “com.opensymphony.xwork2.ActionContext.container”;
Map context;
public ActionContext(Map context) {
this.context = context;
}
public void setActionInvocation(ActionInvocation actionInvocation) {
put(ACTION_INVOCATION, actionInvocation);
}
public ActionInvocation getActionInvocation() {
return (ActionInvocation) get(ACTION_INVOCATION);
}
public void setApplication(Map application) {
put(APPLICATION, application);
}
public Map getApplication() {
return (Map) get(APPLICATION);
}
public static void setContext(ActionContext context) {
actionContext.set(context);
}
public static ActionContext getContext() {
return (ActionContext) actionContext.get();
// Don’t do lazy context creation, as it requires container; the creation of which may
// precede the context creation
//if (context == null) {
// ValueStack vs = ValueStackFactory.getFactory().createValueStack();
// context = new ActionContext(vs.getContext());
// setContext(context);
//}
}
public void setContextMap(Map contextMap) {
getContext().context = contextMap;
}
public Map getContextMap() {
return context;
}
public void setConversionErrors(Map conversionErrors) {
put(CONVERSION_ERRORS, conversionErrors);
}
public Map getConversionErrors() {
Map errors = (Map) get(CONVERSION_ERRORS);
if (errors == null) {
errors = new HashMap();
setConversionErrors(errors);
}
return errors;
}
public void setLocale(Locale locale) {
put(LOCALE, locale);
}
public Locale getLocale() {
Locale locale = (Locale) get(LOCALE);
if (locale == null) {
locale = Locale.getDefault();
setLocale(locale);
}
return locale;
}
public void setName(String name) {
put(ACTION_NAME, name);
}
public String getName() {
return (String) get(ACTION_NAME);
}
public void setParameters(Map parameters) {
put(PARAMETERS, parameters);
}
public Map getParameters() {
return (Map) get(PARAMETERS);
}
public void setSession(Map session) {
put(SESSION, session);
}
public Map getSession() {
return (Map) get(SESSION);
}
public void setValueStack(ValueStack stack) {
put(VALUE_STACK, stack);
}
public ValueStack getValueStack() {
return (ValueStack) get(VALUE_STACK);
}
public void setContainer(Container cont) {
put(CONTAINER, cont);
}
public Container getContainer() {
return (Container) get(CONTAINER);
}
public T getInstance(Class type) {
Container cont = getContainer();
if (cont != null) {
return cont.getInstance(type);
} else {
throw new XWorkException(“Cannot find an initialized container for this request.”);
}
}
public Object get(String key) {
return context.get(key);
}
public void put(String key, Object value) {
context.put(key, value);
}
}
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/195661.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...