首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏DT乱“码”

    ActionContext使用

    (一)通过ActionContext来获取request、session和application对象的LoginAction1 [java] ActionContext context = ActionContext.getContext
    本站的访问量是:${applicationScope.counter}    </body>   (二)直接使用ActionContex类的put()方法 ActionContext.getContext

    69690发布于 2018-02-09
  • 来自专栏全栈程序员必看

    ActionContext_javacontext模式

    Struts2会根据每个执行HTTP请求的线程来创建对应的ActionContext,即一个线程有一个唯一的ActionContext。 在自定义的拦截器中,先获得ActionContext,再通过ActionContext来获得。 在Action中,先获得ActionContext,再通过ActionContext来获得。 在自定义的拦截器中,先获得 ActionContext,再通过ActionContext来获得。 在Action中,先获得ActionContext,再通过ActionContext来获得。 ActionContext actionContext = ActionContext.getContext(); // 获得HttpServletRequest HttpServletRequest 另外,ActionContext还直接提供了ActionContext.getParameters()方法来获得这个Map。

    50610编辑于 2022-09-30
  • 来自专栏全栈程序员必看

    java actioncontext_关于struts2中ActionContext的实现原理

    而又提供了获取Servlet API的其它通道,就是ActionContext(别跟我说还有个ServletActionContext,其实ServletActionContext只是ActionContext 源码为证:public class ServletActionContext extends ActionContext implements StrutsStatics 其次,他也知道,ActionContext 那我们一起来看看吧: 首先是ActionContext类的源码:public class ActionContext implements Serializable{ static ThreadLocal setContext(ActionContext context) { actionContext.set(context); } public static ActionContext getContext () { return (ActionContext)actionContext.get(); } public void setContextMap(Map contextMap) { getContext

    37420编辑于 2022-09-30
  • 来自专栏全栈程序员必看

    通过ActionContext获取request session application 以及ActionContext的简单解析「建议收藏」

    ActionContext:action的上下文对象。 获取application : // 获取ActionContext对象 是action的上下文对象 ActionContext actionContext = ActionContext.getContext 这个时候我们需要看下ActionContext的源码。 map嵌套map, session等对象是放在actionContext的value中.那么我们可以通过debug来获取ActionContext对象吧 通过我们也要根据actionContext的session 结构 差不多分析出来 request在actionContext的存放 应该是类似。

    58820编辑于 2022-09-30
  • 来自专栏全栈程序员必看

    ActionContext_session和page view

    Struts2.0 提供了一个名字为ActionContext的类,在Action中可以通过该类获得Servlet API。    ActionContext是一个Action的上下文对象,Action运行期间所用到的数据都保存在ActionContext中(如Session,客户端提交的参数等信息)。    在Action中可以通过下面的代码来创建和使用ActionContext类,关于该类的方法介绍如下所示: ActionContext ac=ActionContext.getContext(); 以下是ActionContext类的常用方法 1.Object get(Object key) :通过参数key来查找当前ActionContext中的值 2.Map getApplication () :返回一个Application级的Map对象 3.Static ActionContext getContext() :获得当前线程的ActionContext对象 4.Map getParameters

    24930编辑于 2022-09-30
  • 来自专栏行者常至

    (06)Struts2_通过 ActionContext 获取 WEB 资源

    获取 ActionContext 对象 // ActionContext 是 Action 的上下文对象. 可以从中获取到当前 Action 需要的一切信息 ActionContext actionContext = ActionContext.getContext(); / parameters-name=:qbz 总结: 获取 ActionContext 对象: ActionContext actionContext = ActionContext.getContext( 对应的 Map: Map<String, Object> sessionMap = actionContext.getSession(); ActionContext 中手动传入 request 字符串来获取 Map Map<String, Object> parameters = actionContext.getParameters();

    85210发布于 2018-09-19
  • 来自专栏Vincent-yuan

    java之struts2的ThreadLocal和ActionContext

    完成数据迁移是由ActionContext来完成的。 2.ActionContext是Action处理类执行的上下文对象 ActionContext是一个Map结构的对象,属于一个容器。ActionContext是线程安全的。 并且ActionContext在struts2执行过程中负责数据的存储。 ? ActionContext机制是将ServletAPI中的数据进行了解耦,在Action执行过程中,struts2都从ActionContext中获取数据。那么实现线程安全,同时也降低了执行效率。 ActionContext对象中的重要的对象 ? 另外,ThreadLocal的不错参考网址: https://www.cnblogs.com/dolphin0520/p/3920407.html

    65010发布于 2019-09-10
  • 来自专栏全栈程序员必看

    actioncontext的作用_object.java类中的方法

    ActionContext类 常用方法 l getContext():返回ActionContext实例对象; l get(key):相当于HttpServletRequest的getAttribute 访问或添加request/session/application属性 public String execute(){ ActionContext actionContext=ActionContext.getContext (); //往ServletContext中放入app actionContext.getApplication().put("app", "应用范围"); //往session中放入ses actionContext.getSession().put("ses", "session范围"); //往request中放入req actionContext.put("req", "request范围"); return"success"; } 版权声明:本文内容由互联网用户自发贡献

    49340编辑于 2022-09-30
  • 来自专栏LanceToBigData

    struts2(六)之ognl表达式与ActionContext、ValueStack

    3.1、ActionContext   充当OGNL的context。 如果我们使用actionContext.put();  那么会将该键值对直接放入到ActionContext下。   注意:除了request外,其他都可以直接通过getXxx()获得。 从这里actionContext中是不能直接获取到的,request进行了怎样的增强呢? 3.3、ActionContext和valueStack的关系(重要)   也就是说,通过valueStack可以获取到actionContext,通过ActionContext也可以获取到valueStack 获取actionContext的方式     ActionContext.getContext();  //常用     valueStack.getContext(); 四、struts2中使用OGNL

    2.1K70发布于 2018-01-18
  • 来自专栏日常分享

    Struts2+DAO层实现实例03——添加监听器跟踪用户行为

    actionContext=ActionContext.getContext(); Map session=actionContext.getSession(); actionContext=ActionContext.getContext(); Map session=actionContext.getSession(); Userlistener actionContext=ActionContext.getContext(); Map session=actionContext.getSession(); */ public int returnNum(){ ActionContext actionContext=ActionContext.getContext(); actionContext=ActionContext.getContext(); Map session=actionContext.getSession(); ArrayList

    90030发布于 2018-09-04
  • 来自专栏全栈程序员必看

    java中session的使用[通俗易懂]

    1、创建session: ActionContext actionContext = ActionContext.getContext(); Map<String, Object> mapSession = actionContext.getSession(); mapSession.put("branch", branch); mapSession.put("permission", per); 2 out.print("<script>alert('您还没有登录,请登录') </script>"); out.flush(); out.close(); } 3、java后台读取session的值 ActionContext actionContext = ActionContext.getContext(); Map session = actionContext.getSession(); String inputUserid

    72410编辑于 2022-09-07
  • 来自专栏闵开慧

    struts2中action如何获取jsp页面参数

    我们需要在Action中取得request请求参数"username"的值: ActionContext context = ActionContext.getContext();  Map params 一般情况, 我们的ActionContext都是通过: ActionContext context = (ActionContext) actionContext.get();来获取的.我们再来看看这里的 通过ActionContext取得HttpSession: Map session = ActionContext.getContext().getSession(); 2. ServletActionContext和ActionContext联系 ServletActionContext和ActionContext有着一些重复的功能,在我们的Action中,该如何去抉择呢? 注意:在使用ActionContext时有一点要注意: 不要在Action的构造函数里使用ActionContext.getContext(),因为这个时候ActionContext里的一些值也许没有设置

    2.9K150发布于 2018-03-30
  • 来自专栏Vincent-yuan

    java之struts2之ServletAPI

    解耦合方式 ---- 解耦合方式---ActionContext : 解耦合方式获取的都是map对象 1   //登录 2 public String login(){ 3 user.getName())&&"1111".equals(user.getPwd())){ 4 //登录成功 数据存入Session中 5 //通过ActionContext 可以获得Session 6 Map<String,Object> session = ActionContext.getContext().getSession(); 7 ().get("request"); 12 Map<String,Object> application = ActionContext.getContext().getApplication 可以不在Servlet容器环境中使用 2.耦合方式获取ServletAPI ---- 下面讲的是耦合方式获取的Servlet对象 2.1 通过ActionContext获取   //登录 public

    56230发布于 2019-09-10
  • 来自专栏销声匿迹

    WebAPI问题追踪日志记录过滤器

    ActionFilterAttribute { public override void OnActionExecuting(Controllers.HttpActionContext actionContext ) { LogHelper.Warn(actionContext.ActionDescriptor.ActionName + "进入执行:", Utils.SerializeObject (actionContext.ActionArguments)); base.OnActionExecuting(actionContext); } ); LogHelper.Error(actonName + "异常参数:", Utils.SerializeObject(actionExecutedContext.ActionContext.ActionArguments { LogHelper.Warn(actonName + "成功退出执行:", Utils.SerializeObject(actionExecutedContext.ActionContext.ActionArguments

    75110发布于 2020-09-03
  • 来自专栏玩转JavaEE

    听说 TCC 不支持 OpenFeign?这个坑松哥必须给大家填了!

     rollback(BusinessActionContext actionContext) {         return accountService.rollbackDeduct(actionContext (BusinessActionContext actionContext) {         return orderService.rollbackOrder(actionContext);       = (String) actionContext.getActionContext("productId");         Integer count = (Integer) actionContext.getActionContext  rollback(BusinessActionContext actionContext) {         return storageService.rollbackDeduct(actionContext  = new BusinessActionContext();         actionContext.setXid(xid);         storageServiceApi.deduct(actionContext

    54320编辑于 2022-06-06
  • 来自专栏平凡少年

    WebApi 服务监控

    OnActionExecuted(HttpActionExecutedContext actionExecutedContext) 和OnActionExecuting(HttpActionContext actionContext "_thisWebApiOnActionMonitorLog_"; public override void OnActionExecuting(HttpActionContext actionContext ) { base.OnActionExecuting(actionContext); WebApiMonitorLog MonLog = ; MonLog.HttpRequestHeaders = actionContext.Request.Headers.ToString(); MonLog.HttpMethod = actionContext.Request.Method.Method; actionContext.Request.Properties[Key]

    1.4K30发布于 2019-04-11
  • 来自专栏行者常至

    (07)通过 Aware 接口获取 WEB 资源

    通过 Aware 接口获取 WEB 资源 在上一节中介绍了用ActionContext来获取WEB资源。 获取 ActionContext 对象 // ActionContext 是 Action 的上下文对象. 可以从中获取到当前 Action 需要的一切信息 ActionContext actionContext = ActionContext.getContext(); / 获取 application 对应的 Map, 并向其中添加一个属性 // 通过调用 ActionContext 对象的 getApplication() 方法来获取 application 对象的 Map 对象 Map<String, Object> applicationMap = actionContext.getApplication(); // 设置属性

    50120发布于 2018-09-19
  • 来自专栏张善友的专栏

    ASP.NET Web API 接口执行时间监控

    string Key = "__action_duration__";         public override void OnActionExecuting(HttpActionContext actionContext )         {             if (SkipLogging(actionContext))             {                 stopWatch.Elapsed));             }         }         private static bool SkipLogging(HttpActionContext actionContext )         {             return actionContext.ActionDescriptor.GetCustomAttributes<NoLogAttribute >().Any() ||                     actionContext.ControllerContext.ControllerDescriptor.GetCustomAttributes

    2.4K80发布于 2018-01-22
  • 来自专栏全栈程序员必看

    初识不知曲中意,再听已是曲中人下一句是什么_调用action方法出错

    在每次动作执行前,核心控制器StrutsPrepareAndExecuteFilter都会创建一个ActionContext和ValueStack对象。且每次动作访问都会创建。 contextMap 使用 struts内置标签 <s:debug> 查看contextMap数据 利用ActionContext存数据 import com.opensymphony.xwork2 .Action; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionSupport; 对象 直接存储key value对象 ActionContext contextMap = ActionContext.getContext(); contextMap.put("username"," 对象获取 ValueStack valueStack = ActionContext.getContext().getValueStack(); valueStack.push(new Student(

    57740编辑于 2022-09-30
  • 来自专栏码猿技术专栏

    Struts2之Action类访问Servlet API

    但是对于web应用控制器而言,不访问Servlet API是不可能,因此下面我们介绍三种方式访问Servlet API ActionContext 使用这个可以获取Servlet中HttpServletRequest ,HttpSession,ServletContext 其中的方法 static ActionContext getContext()返回一个实例化ActionContext对象,用于调用下面的方法 Object get(key) 返回ActionContext中存放的键值对的值 其实这里获取的是Servlet中HttpServletRequest对象的属性 Object put(key,value) 向ActionContext actionContext=ActionContext.getContext(); //获取实例化对象 //向request域中存放键值对 actionContext.put //向session中存放键值对 actionContext.getSession().put("password", "123456"); ​ //向

    1.5K50发布于 2018-05-10
领券