Three ways to use ActionContext class to operate api

									request session application

ActionContext context= ActionContext.getContext();
Map<String,Object>request=(Map<String,Object>)context.get(“request”)
Map<String,Object> session = context.getSession();
Map<String,Object>application=context.getApplication();
可以向操作Map一样去操作以上对象
存 request.put(“name”,“v1”);
session.put(“name”,“v1”);
application.put(“name”,“v1”);
取 request.get(“name”);
session.get(“name”);
application.get(“name”);

====================================
page access
-> use EL expression to get the object stored in the domain The value in
${requestScope.name}
${sessionScope.name}
${applicationScope.name}


++++++++++++++++++++++++++++++++++++++
Request forwarding is valid: request session application ActionContext
redirection is valid: session application
[Note]
Because the ActionContext object itself is a container, and its life cycle is equivalent to request. Therefore, it is not recommended to use the request domain object in struts2, and it is recommended to directly use the ActionContext object to access the value. Use any object to store the value, use which object to get the value
ActionContext context = ActionContext.getContext();
context.put("x", 1);

Guess you like

Origin blog.csdn.net/weixin_44703894/article/details/111562139