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无耦合的方式 立即下载

相关推荐

Abaqus中Cohesive单元建模:从本构到失效的完整指南

本文提供了Abaqus中Cohesive单元建模的完整指南,涵盖从本构模型到失效分析的全过程。详细解析了Cohesive单元作为模拟界面粘结与失效的关键工具,其核心在于弹性本构、损伤起始准则和损伤演化定律的设置。文章通过双悬臂梁(DCB)实例,手把手指导前处理、材料定义、求解设置及后处理分析,并分享了刚度、强度、断裂能等关键参数的影响与收敛性调优的实用避坑技巧,帮助用户准确模拟复合材料及胶接结构的界面失效行为。

cuda7parallel的博客 713

Struts2 访问request session application对象

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

qq_36074113的博客 498

Opencv4.5.1 微信二维码识别功能 QRCode 编译与使用 C++

部分参考:https://mp.weixin.qq.com/s/2GZAJAUPHTXFOKDRv-D21Q 一、下载源码 https://github.com/opencv 二、源码编译 ① 在cmake中添加源码编译路径和生成路径,第一次点击configure。 ② 添加contrib路径 第一次configure后,找到OPENCV_EXTRA_MODULES_PATH,将contrib路径添加进来,注意要具体到modules/,继续configure。 ..

zaibeijixing的专栏 1万+

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

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

知且行的博客 1033

new delete 详解

常规的new 和 delete 当需要内存时,可以使用new申请内存,但在用完内存时应当使用delete 去归还内存,以防止内存泄漏,具体使用方案见下面代码: int* ps = new int ; // 使用new 申明变量空间 ... ... delete ps ; '// delete 删除所申明的变量空间 上述代码将删除ps 指针指向的内存空间,但不会删除指针本身,即仍然可以使用该指针去指向其他int 类型的变量。new 和 delete 一定需要成对的使用否则极易发生内存泄漏。 注意:不

qq_42138448的博客 6945

模仿学习(Imitation Learning)概述

什么是模仿学习呢?简单来说,模仿学习(Imitation Learning),就是要训练机器能够复制人类的连续动作,进而达到模仿的目的。其实,Imitation Learning的实用性很高,假设今天有一个训练场景,你不知道该怎么定奖励值(reward),但是你可以收集到专家的示范数据(expert demonstration data),你就可以考虑用Imitation Learning这个方法。因此,模仿学习也被寄予很高的期待,成为下一代强人工智能的关键技术。......

qq_22749225的博客 2万+

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

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

wangminshe89 183

Cesium功能集(十二):Cesium中流体仿真

【代码】Cesium功能集(十二):Cesium中流体仿真。

GIS肆月 610

Struts2 Action访问Web对象的四种方式

1.创建Request,Session,Application的Map对象 action: Map request; Map session; Map application; public UserAction1(){ System.out.println("UserAction1..."); request = (Map) ActionContext.getConte

wyc2410的专栏 812

一文就够-InfiniBand 技术全面解析:从原理到实践的通俗易懂指南

想象一下,在一个超级数据中心里,成千上万台服务器需要像蜜蜂群体一样高效协作。如果用传统的网络连接,就像让每只蜜蜂都排着队传递消息,效率极低。InfiniBand(简称 IB)就是为了解决这种 "通信拥堵" 而生的高速网络技术,它专门为高性能计算(HPC)、数据中心和云计算环境设计,就像给服务器之间搭建了多条高速公路,让数据可以飞驰而过。

jundao1997的专栏 1409

YOLOv11改进 | 注意力篇 | YOLOv11引入CBAM注意力机制

我们的实验表明各种模型的分类和检测性能得到了一致的改进,证明了 CBAM 的广泛适用性。简单介绍:CBAM的主要思想是通过关注重要的特征并抑制不必要的特征来增强网络的表示能力。模块首先应用通道注意力,关注"重要的"特征,然后应用空间注意力,关注这些特征的"重要位置"。到此本文的正式分享内容就结束了,在这里给大家推荐我的YOLOv11改进有效涨点专栏,本专栏目前为新开的,后期我会根据各种前沿顶会进行论文复现,也会对一些老的改进机制进行补充,如果大家觉得本文帮助到你了,订阅本专栏,关注后续更多的更新~

tsg6698的博客 2万+

Struts2访问request、session、application对象

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

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

复旦微FMSH_Procise安装全流程详解:从环境配置到实战避坑指南

通过本文的全流程解析+实战技巧,开发者可快速掌握Procise在复旦微芯片开发中的核心应用。未来随着AKConv轻量级架构(参考往期文章)等创新技术的融入,国产芯片开发生态将更加完善。立即关注本专栏,获取最新多镜像切换指南与Linux SDK实战教程!扩展阅读复旦微在线升级BOOT.BIN全解析H7-TOOL实现复旦微脱机烧录(注:本文实验环境为Windows 10 x64 + FMQL45T-CORE开发板,部分操作可能因版本更新调整)立即行动下载本文配套配置文件:[GitHub链接]加入技术交流群。

QQ_778132974的博客 3259

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

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

qq_36074042的博客 341

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

深度学习工具包 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 访问request、session和application对象

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

zdy32032319861105的专栏 634

精雕软件(JDpaint) 5.5 绿色版

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

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

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

Fish198398的专栏 233

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

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
上一篇: Struts 拦截器 、
下一篇: Spring Struts2 Hibernate - - xml版 demo整合
火火儿
博客等级 码龄10年 90粉丝 104原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值