Struts2 访问request session application对象

Struts2访问request,session,application的四种方式 NULL 博文链接:https://aimilin6688.iteye.com/blog/1279546 立即下载

Struts2提供了了多种方式来访问上述的三种现象,归结起来,可以划分为两大类:与Servlet API 解耦的访问方式和与Servlet API耦合的访问方式。


一. 与Servlet API 解耦的访问方式

    为了避免与Servlet API 耦合在一起,方便Action类做单元测试,Struts2对HttpServletRequest,HttpSession和ServletContext进行了封装,构造了三个Map对象来替代这三种对象,在Action中,直接使用HttpServletRequest,HttpSession和ServletContext对应的Map对象来保存和读取数据。

    要获取这三个对象,可以使用com.opensymphont.xwork2.ActionContext类。

     ActionContext是action执行的上下文,在ActionCOntext中保存了action执行所需的一组对象,包括parameters,request,session,application和locale等。ActionContext类定义了如下方法,用于获取HttpServletRequest,HttpSession和ServletContext对应的Map对象。

    01.public Object get(Object key)

      ActionContext类没有提供类似getRequest()这样的方法来过去封装了HttpServletRequest的Map对象。要得到请求Map对象,你需要为get()方法传递参数“request”。

    02.public Map getSession()

     获取封装了HttpSession的Map对象。

    03.public Map getApplication()

    获取封装了ServletCOntext的Map对象。



案例:登录进入成功页面,显示用户名。


package cn.action;

import cn.entity.User;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.ServletActionContext;

import java.util.Map;

/**
 * Created by micro on 2017/10/21.
 */
public class LoginAction implements Action,ModelDriven{

    private User user=new User();


    public String execute() throws Exception {
        if ("admin".equals(user.getName())&&"123".equals(user.getPassword())){

            //解耦方式
            ActionContext context = ActionContext.getContext();
            //request
            Map request= (Map)context.get("request");
             //application
            Map<String, Object> application = context.getApplication();
           //session
Map<String, Object> map = context.getSession();
      map.put("uname",user.getName());        
    //值栈 页面直接用  ${uname} 获取值         
   //方式一:   
         /*ValueStack valueStack = context.getValueStack();     
       valueStack.push(map);*/       
     //方式二:     
       HttpServletRequest request = ServletActionContext.getRequest();    
        ValueStack vs= (ValueStack)request.getAttribute("struts.valueStack"); 
           vs.push(map);     
                return "success";  
      }        return "input";   
 }   
 public User getUser() {    
    return user;   
 }   
 public void setUser(User user) {   
     this.user = user;  
  }   
 public Object getModel() {   
     return user;   
 } 
 }


struts.xml

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
        "http://struts.apache.org/dtds/struts-2.3.dtd">

<struts>

    <constant name="struts.devMode" value="true"/>

    <package name="default" namespace="/" extends="struts-default">    

        <action name="loginAction" class="cn.action.LoginAction">
            <result name="success">/success.jsp</result>
            <result name="input">/login.jsp</result>
        </action>
    </package>

</struts>








login.jsp

<%@page language="java" contentType="text/html; utf-8" %>
<%@taglib uri="/struts-tags" prefix="s"%>
<title>登录</title>
<html>
<body>
<s:form name="form1" namespace="/" method="POST" action="loginAction">
    用户名:<s:textfield name="name"></s:textfield>
    密码:  <s:textfield name="password"></s:textfield>
    <s:submit value="登录"></s:submit>
</s:form>
</body>
</html>






success.jsp




<%@page language="java" contentType="text/html; utf-8" isELIgnored="false" %>
<%@taglib uri="/struts-tags" prefix="s"%>
<html>
<body>

<!--方式一:-->
<s:property value="#session.uname"/>

<!--方式二: 值栈-->
${uname}


</body>
</html>



除了利用ActionContext‘来获取request,session和application对象这种方式,Action类可以实现某些特定的接口,让Struts2框架在运行是向Action实例注入request,session和application对象。与之对应的三个接口和它们的方法如下:



二.与Servlet API 耦合的方式



public class LoginAction implements Action,ModelDriven{

    private User user=new User();

    
    public String execute() throws Exception {
        if ("admin".equals(user.getName())&&"123".equals(user.getPassword())){

      

            //耦合方式一:
          
            HttpSession session = ServletActionContext.getRequest().getSession();
            session.setAttribute("uname",user.getName());

            ServletContext servletContext = ServletActionContext.getServletContext();
            servletContext.setAttribute("unames",user.getName());
return "success";
    }    
   return "input";  
  }  
  public User getUser() {     
   return user;  
  }  
  public void setUser(User user) {     
   this.user = user;  
  }   
 public Object getModel() {   
     return user;  
  }





package cn.action;

import cn.entity.User;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.util.ServletContextAware;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;


/**
 * Created by micro on 2017/10/21.
 */
public class LoginAction implements Action,ModelDriven,ServletRequestAware,ServletContextAware {

    private User user=new User();

    HttpServletRequest request;
    ServletContext context;

    public String execute() throws Exception {
        if ("admin".equals(user.getName())&&"123".equals(user.getPassword())){         

            //耦合方式二:实现ServletRequestAware接口  给request对象赋值 ServletContextAware接口给contest对象注入
            HttpSession session = request.getSession();
            session.setAttribute("uname",user.getName());


            return "success";
        }
        return "input";
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public Object getModel() {
        return user;
    }

    public void setServletRequest(HttpServletRequest httpServletRequest) {

        this.request=httpServletRequest;
    }

    public void setServletContext(ServletContext servletContext) {
        this.context=servletContext;
    }
}

总结:

直接用action对象接收用户输入的数据,分别是Servlet API 解耦方式和Servlet API 耦合方式。



struts2访问request,session,application作用域 本文讲述了serlvet API无耦合的方式 立即下载

相关推荐

USB-C快充协议分析仪:QC/PD双协议识别与功率监测设计

USB-C快充协议是现代移动设备能量传输的核心技术标准,其本质是通过物理层电压特征(如DP/DM组合、CC线BMC编码)实现动态电压协商。理解协议握手原理对充电器研发、兼容性测试及故障诊断至关重要。本方案聚焦受电端(Sink)视角,基于FUSB302B与高阻抗DP/DM采样电路,实现QC2.0/QC3.0/QC4+与PD2.0/PD3.0的实时识别与状态机解析;结合INA219高精度电流检测与μs级同步采样,达成±0.06%功率测量精度。典型应用于快充芯片验证、产线协议一致性测试及第三方评测,为USB供电系

weixin_42153793的博客 255

Struts2 学习总结(三):Struts2在action中访问request,application,session对象的方式

接下来介绍Struts2中访问request,application,session对象的方式 在上面介绍了通过action访问用户输入,从而替代了访问HTTP Servlet Request,实现了与web层的解耦,但在某些特殊场景中,action中需要访问这些对象。Struts提供了多种方式访问这些对象,可以将这些方式大体分为两类: 与Servlet API解耦的方式和与Servlet A...

知且行的博客 1033

STK相关总结

STK简介 一.SIM卡应用工具包(SIM Application Toolkit),又名CAT/USAT,它包含一系列终端与SIM卡的交互指令,SIM卡可以应用卡内的小应用程序和终端交互,从而实现增值服务的目的,STK包括三种类,STK-imsi切换,STK –OTA,STK-BIP 功能: (1) Profile download:配置下载,开机初始化SIM卡过程中,终端告诉SIM卡终端支持哪些功能,STK中download指终端将数据发送给SIM卡 (2) Proactive command: 主动式

jingjing_2的博客 3369

在Struts2中访问Web页面元素request、response、session、application的四种方法

在Struts2中获取Web页面元素request、response、session、application有两种形式,一种是Map类型,另一种是真实类型HttpServletRequest, HttpSession, ServletContext的引用。一共有四种获取方法 ,如下所示: 第一种:依赖于容器,Map类型: private Map request; private Map...

wangminshe89 182

计数译码驱动显示电路实验报告_京东方G0A电路、阵列基板、显示 装置及驱动方法广州威彩...

图1、实施例二所述的选择子单元的结构示意图图2、实施例四所述的GOA电路结构示意图图3、实施例七所述的阵列基板的局部结构示意图图4、实施例所述的极性反转驱动方法的第一场的各信号时序图图5、实施例所述的极性反转驱动方法的第二场的各信号时序图图6、实施例所述的极性反转驱动方法的第三场的各信号时序图图7、实施例所述的极性反转驱动方法的第四场的各信号时序图图8、为图4所示时序下,实施例八所述显示...

weixin_35696112的博客 930

【CMU-自主导航与规划】Autonomous Exploration Development Environment 实战:从环境搭建到多场景测试

本文详细介绍了CMU开源自主导航开发环境(Autonomous Exploration Development Environment)的实战部署与测试。内容涵盖从Ubuntu与ROS环境搭建、仿真场景配置,到核心导航模块(地形分析、局部避障、航点跟踪)的深度解析,并演示了如何集成TARE探索与FAR规划等上层算法,最终指导连接真实SLAM与实车部署,完成多场景性能评估。

weixin_29215391的博客 716

Struts2访问ServletAPI(向JSP内置对象request,session,Application传值)

JSP:         request                                 session                                   application Servlet:HttpServletRequest            HttpSession                            ServletContext

策马扬鞭追蜗牛 827

一人公司 CEO × Accio Work:最大能效实战指南

作为一人公司 CEO,你需要同时扮演市场、销售、运营、财务、产品等多个角色。Accio Work 本质上就是你的。

华盛AI的博客 2127

Struts2访问web元素(包括:request,session,application)的4种方法

Struts2访问web元素(包括:request,session,application和HttpServletRequest,HttpServletSession, HttpServletContext)的4种方法 说明: 1.常用的是第二中方法取到,Map类型的request,session,application的引用 2.request,session,applicat

MJZ_CSDN的专栏 713

ADS2023实战:手把手教你用Load-Pull设计40W LDMOS功率放大器(附工程文件)

本文以飞思卡尔MRF8P9040N LDMOS晶体管为例,详细介绍了在ADS 2023中设计一款40W功率放大器(PA)的全流程。内容涵盖从直流偏置设置、稳定性分析、核心的负载牵引(Load-Pull)仿真,到基于Smith圆图的匹配网络设计、谐波平衡性能验证,直至版图生成与优化。文章提供了手把手的实战指导和工程文件,旨在帮助射频工程师掌握高效率PA的设计方法与关键技巧。

cake8的博客 1083

【宝藏级】全网最全的Pandas详细教程(2万字总结)

【回炉重造】Python之Pandas详细教程前言为什么要学习pandas?什么是Pandas?官网1. Pandas的索引操作索引对象Index {#索引对象index}1. Series和DataFrame中的索引都是Index对象2. 索引对象不可变,保证了数据的安全常见的Index种类Series索引 {#series索引}1. index 指定行索引名2. 行索引3. 切片索引4. 不连续索引5. 布尔索引DataFrame索引1. columns 指定列索引名2. 列索引3. 不连续索引高级索引

全网粉丝30W+,CSDN、稀土掘金人工智能领域签约作者,人工智能、大模型、Python 爬虫,商务合作,请私信沟通。 6万+

Struts2访问request、session、application对象

一、与Servelt API解耦访问方式  为了避免与Servlet API耦合在一起,方便Action类做单元测试,Struts 2对HttpServletRequest、HttpSession和ServletContext进行了封装,构造了三个Map对象来替代这三种对象,在Action中,直接使用HttpServletRequest、HttpSession和ServletContext对应的

态度决定思路,思路决定出路!!! 595

Open3D (C++) 点云边界提取【2025最新版】

Compute the boundary points of a point cloud.The implementation is inspired by the PCL implementation. Reference:https://pointclouds.org/documentation/classpcl_1_1_boundary_estimation.html

点云侠的博客 878

Struts2 访问request session application对象 。

Struts2提供了了多种方式来访问上述的三种现象,归结起来,可以划分为两大类:与Servlet API 解耦的访问方式和与Servlet API耦合的访问方式。 一. 与Servlet API 解耦的访问方式     为了避免与Servlet API 耦合在一起,方便Action类做单元测试,Struts2对HttpServletRequest,HttpSession和S

weixin_36024620的博客 278

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

Struts 2 访问session request application 对象的方式

Struts2提供了了多种方式来访问上述的三种现象,归结起来,可以划分为两大类:与Servlet API 解耦的访问方式和与Servlet API耦合的访问方式。 一. 与Servlet API 解耦的访问方式     为了避免与Servlet API 耦合在一起,方便Action类做单元测试,Struts2对HttpServletRequest,HttpSession和S

qq_36074042的博客 341

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

Struts2 访问request、session和application对象

<br />Struts2 访问request、session和application对象 <br />在 传统的Web开发中,经常会用到Servlet API中的HttpServletRequest、HttpSession和ServletContext。Struts 2框架让我们可以直接访问和设置action及模型对象的数据,这降低了对HttpServletRequest对象的使用需求,但在某些应用中,我们可 能会需要在action中去访问HttpSe

zdy32032319861105的专栏 634

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Struts2学习笔记(三) Struts2中访问request,session,和application对象

访问request,session,和application对象 Struts2提供了多种方式来访问request,session,application三种对象,归结起来,可以划分为两大类,与Servlet API解耦方式和与Servet API耦合的访问方式. 1.与Servlet API 解耦的访问方式: 为了避免与Servlet API耦合在一起骑,为方便Action...

Fish198398的专栏 233

Struts2中访问request,session,和application对象

访问request,session,和application对象     Struts2提供了多种方式来访问request,session,application三种对象,归结起来,可以划分为两大类,与Servlet API解耦方式和与Servet API耦合的访问方式. 1.与Servlet API 解耦的访问方式:     为了避免与Servlet API耦合在一起骑,为方便Action

1156

Struts2中request、response、session、application对象的访问方法

1.ActionContext context=ActionContext.getContext(); HttpServletRequest request = (HttpServletRequest)context.get(ServletActionContext.HTTP_REQUEST); 2.实现指定的接口implements ServletRequestAware public

zrxJuly 401

struts2中freemarker访问request session Application parameter对象

struts2 freemarker request session parameter 使用Request里的Attribute值最简单的方法就是直接${AttributeName}或者安全一点:${AttributeName!"default Value"} 1.取Application范围的对象 xml 代码    1.      2.      ${Appl

萧若寒 1708

struts2 Action 访问web对象(request,session,application)

Struts2 Action 访问web对象一共有四种,分别是: 一、创建request,session,application的Map对象 二、实现RequestAware,SessionAware,ApplicationAware接口(IOC注入) 三、创建传统的HttpServletRequest,HttpSession,ServletContext对象 四、实现ServletReq

夜子的专栏 876

struts2如何访问request、session和application对象

小结下在struts2中如何访问request、session和application对象 总共有四种方式: 1.是否与servlet耦合----是否使用servlet子类对象 2.是否IOC--是否返回map类型对象 (1)ActionContext对象-----IOC,不与servlet耦合 三种方法返回值都是map类型的对象 ActionContext.getContex...

jeffsui的专栏 162
上一篇: Stuts2入门案例
下一篇: Struts2深入详解--- 认识Struts2
倩倩之
博客等级 码龄10年 304粉丝 98原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值