Struts2新建Action类的方式

Struts2框架中Action参数获取的三种实现方式 模型-视图-控制器(MVC)是软件开发中的一种架构模式,它将应用程序分为三个核心组件:模型(Model)、视图(View)和控制器(Controller)。模型代表数据和业务逻辑,视图是用户界面,控制器处理输入,将命令传递给模型和视图。MVC模式的主要目的是实现一种分层架构,以降低模块间的耦合度,提高系统的可维护性和可扩展性。Struts2是一个基于MVC模式的Java Web框架,由Apache软件基金会开发。它的设计目标是简化企业级Web应用程序的开发。 阅读详情

方式一:创建一个类,可以是POJO

POJO:不用继承父类,也不用实现任何接口,使Struts2框架的代码侵入性更低

public class Demo3Action {
	
	public String execute() throws Exception {
		return "success";
	}
}

方式二:实现一个接口Action,里面有execute方法,提供action方法的规范,并且 Action接口预置了一些字符串 

import com.opensymphony.xwork2.Action;

public class Demo4Action implements Action{

	@Override
	public String execute() throws Exception {
		return SUCCESS;
	}

}

方式三:继承一个类ActionSupport,这个类已经帮我们实现Action, Validateable, ValidationAware, TextProvider, LocaleProvider,如果我们需要用到这些接口的实现时,不需要自己来实现了(推荐使用)

import com.opensymphony.xwork2.ActionSupport;

public class Demo5Action extends ActionSupport {

      public String execute() throws Exception {
		return SUCCESS;
	  }

}

 

2025.06.06【Ribo-seq】|riboWaltz:P-site定位与三碱基周期性分析流程 同学们,大家好!今天我们要学习的是riboWaltz——一款专为Ribo-seq(核糖体足迹测序)数据设计的R包,主要用于P-site定位优化和三碱基周期性分析。P-site的准确定位是Ribo-seq下游所有翻译组学分析的基础,riboWaltz为我们提供了系统、可视化、易用的解决方案。P-site定位优化:自动识别不同长度RPF的最佳P-site偏移量。三碱基周期性分析:可视化RPF在CDS、UTR等区域的分布,评估数据质量。多样本/多条件支持:可同时处理多个样本,便于批量分析和对比。 阅读详情

相关推荐

态路小课堂丨三款800G光模块方案介绍—SR8/DR8/2FR4

800G QSFP-DD 2FR4光模块使用CWDM4波长(1271/1291/1311/1331nm),单通道速率为100G,通过MUX减小光纤的数目,其光学接口采用CS接口或双芯LC接口。

poposu的博客 2402

Struts2框架Action类创建的三种方式

     总共有三种方式:1、       pojo类package cn.hd.hello;/** 1.pojo 类的创建方式(Plain Ordinary Java Object)*        典型的普通的Java对象 没有实现接口 没有继承 这样的方式就是pojo类*    相较于Servlet的设计方式:低侵入性  比Servlet这种继承要好** */public class Hel...

臆想的一只猫 1256

卫星通信系统工程设计:从链路预算到地面站部署全流程解析

卫星通信系统设计是一项融合需求分析、链路预算、频率规划与设备选型的复杂工程,其核心在于把业务需求转化为可计算的工程参数。链路预算作为设计的关键环节,通过EIRP、G/T值、自由空间损耗与雨衰余量的逐项拆解,决定了系统在恶劣天气下的可用度与稳定性。掌握这些基础原理,不仅有助于合理选择天线口径与功放配置,也能有效规避邻星干扰与极化失配等工程陷阱。在VSAT组网、应急通信、远程宽带接入等场景中,科学的设计框架能显著降低建设成本并提升运行可靠性。围绕卫星通信系统工程设计全流程,梳理从需求分析到地面站部署的完整链路,

weixin_33393017的博客 77

Struts2 创建Action对象并放入ValueStack的时机

1. 创建一个简单的Actionpackage com.web; public class UserAction { private String name; public UserAction(){ //随便加一行代码并添加断点 System.out.println("==创建UserAction对象=="); } public St

孔繁玉的专栏 1104

10bit SAR ADC 学习笔记——CDAC

SAR ADC(逐次逼近型模数转换器)的工作原理是基于二进制搜索算法和逐次逼近技术来实现的模拟信号到数字信号的转换。SAR ADC的工作原理使其具有高精度、低功耗和可扩展性强的特点。通过逐次逼近技术,SAR ADC可以逐步减小转换误差,提高转换精度。此外,由于其结构简单,SAR ADC的功耗较低,适用于对功耗要求较高的电子设备。同时,SAR ADC的结构易于实现和扩展,可以根据需要增加比特位数以提高转换精度。

u011376987的博客 1万+

OpenClaw:深度学习驱动的智能编程工具实战解析

智能编程工具通过深度学习技术革新传统开发流程,其核心在于代码语义理解与实时协作能力。这类工具采用AI代码补全、错误预测等技术,显著降低开发者认知负荷,尤其适用于复杂业务逻辑开发和遗留系统维护场景。以OpenClaw为例,其智能填充和上下文感知功能可提升40%编码效率,减少65%调试时间。关键技术实现包含自然语言处理、代码静态分析等,在金融科技、电商系统等领域具有广泛应用前景。热词提示:代码理解引擎、智能工作流整合展现了当前AI辅助开发的最新趋势。

chubaisheng8627的博客 326

Struts2的Action创建方式

在struts2框架中action类代替了servlet的地位,原因是action类里面封装了很多的方法,可以直接拿来使用而不必要再自己手动创建,因此,action的创建也存在着几种方式,各位看官请看下面的笔记~ Struts2的Action创建1、Struts2的Action创建方式1.1、POJO方式创建Action1.2、实现一个接口的方式创建Action1.3、继承一个类的方式创建Act...

༺清风暖云༻ 511

Win11+VSCode+TeXLive:学术党必备的LaTeX环境配置避坑指南(2024最新版)

本文详细介绍了如何在Windows 11系统下,通过VSCode编辑器与TeXLive发行版配置高效的LaTeX学术写作环境。针对国内用户常见的镜像下载慢、插件配置复杂等问题,提供了优化方案和避坑指南,帮助科研人员和学生快速搭建流畅的学术写作工作流。

plum99的博客 639

Struts2 Action类的创建以及参数传递以及接收

一、Struts中Action得创建方式 1,直接创建一个简单的Action类 添加Struts.xml,配置转发方法返回转发的页面。 2,实现一个Action类 Strust.xml配置对应的Url转发映射。 3,继承一个ActionSupport类 struts.xml配置文件的内容如下: 二、Struts中Acti...

weixin_30540691的博客 311

向量库深度解析:选型、索引原理与生产实践

本文系统解析五大主流向量库(pgvector、Milvus、Weaviate、ChromaDB、Faiss)的定位、优缺点与适用场景,深入拆解FLAT、IVF、HNSW等核心索引原理,并重点分析Milvus的Compaction机制。针对数据治理场景,提供精准选型建议:中小规模优先pgvector或Weaviate,超大规模选择Milvus,开发测试推荐ChromaDB。核心索引推荐HNSW,兼顾检索速度与召回率。全文从理论到实践,为开发者提供清晰的向量库选型逻辑与生产落地指南。

a123147abc的博客 367

在 SAP 资产模块跨 2024 和 2025 两个年度操作后,运行 AFAB 测试无数据,大概率是折旧已完全过账、跨期配置异常或资产数据异常等原因

SAP资产模块跨年度操作AFAB测试无数据的排查方案:首先检查折旧是否已完全计提,确认资产主数据价值;其次验证跨年度配置是否合规,包括全局配置、折旧范围和账期状态;然后重新执行AFAR折旧计算刷新数据;排查资产主数据异常或业务操作冲突;最后核对AFAB运行参数是否正确设置,包括会计年度、期间范围和运行模式等。

金牌架构师 870

Struts2教程之二Action创建方式

三种常用方式创建: 第一种:实现Action接口 package com.qfedu.web.action; import com.opensymphony.xwork2.Action; /** *@Author feri *@Date Created in 2018/7/4 10:10 * Action的创建方式 第一种:实现接口 */ public class Create...

程序员Feri 388

OpenClaw插件开发指南:扩展AI智能体的无限可能

OpenClaw插件开发指南介绍了如何扩展AI智能体的功能。该插件系统支持多种类型(功能、集成、工具、界面、工作流插件),具有模块化、低耦合等优势。开发环境需要安装SDK和工具包,通过plugin.json配置插件信息,主文件实现核心功能。API提供智能体管理、任务执行等接口,示例演示了文本处理插件的创建流程。开发者可基于此框架灵活扩展OpenClaw的能力。

一键难忘的博客 568

Struts2入门

简单配置 1.新建一个action类 注意:类里面的方法名,返回类型,访问属性是固定的 2.在你下载的Struts2环境下的apps下有一个struts2-blank.war,解压它(可以放到tomcat的webapps下启动tomcat自动解压,也可以把后缀改成.zip解压),里面会有一个struts.xml(仔细找,能找到的),复制到你项目下的src下,配置如下 packa...

Luo_Dong的博客 202

vb 6.0并口开发操作实例

vb6并口开发,简体中文,试例内有inpout32.dll动态链接库

深度学习工具包 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中Action接收请求参数的方式

Struts2中Action接收请求参数的方式1、以Servlet的方式获取1.1、新建登录页面1.2、加载顺序1.3、default.properties的默认配置1.4、修改struts2的访问后缀1.5、配置struts2的开发模式2、配置文件的主要元素2.1、package元素2.2、action元素2.3、result元素 1、以Servlet的方式获取 1.1、新建登录页面 1.2、加载顺序 顺序 配置文件名 所在位置 说明 1 default.properties strut

爱心家园的博客 291

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

struts2框架中Action的三种编写方式

一、Action的三种编写方式:1、实现Action类2、继承ActionSupport接口3、自己定义pojo类(没有继承类,也没有实现任何接口)、1、实现Action类*Action接口中包含5个常量和一个execute方法 *5个常量分别是: *1、 public static final String SUCCESS = "success";表示运行成功时返回的逻辑视图 *2、 publi...

黑彩侠的博客 2688

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

struts中的action和Action类以及struts2中如何在Action类中获得servlet api的域对象

1.Struts2的学习中大家都会遇到action和与action对应的Action类,那么什么是action什么是action对应的Action类呢? 例如struts.xml的配置文件如下: action:代表一个struts2的请求,对应的是Action类的一个方法。 Action类:表示处理多个action请求的普通javabean。也就是配置文件中节点中对应的class配置

nihaowoshiyudong的博客 2233

struts2_Action的基本使用

Actions是Struts2框架的核心,因为它们适用于任何MVC(Model View Controller)框架。 每个URL映射到特定的action,其提供处理来自用户的请求所需的处理逻辑。 Struts2框架是类级别的拦截,每次来了请求就创建一个Action,然后调用get和set方法把request中的数据注入。 创建Action类 实现Action接口 // // Sourc...

Onion的博客 2616

Struts2--Action的实现方式与配置详解

Action Action 是用于处理请求操作的,它是由 StrutsPrepareAndExecuteFilter 分发过来的。 在 Struts2 框架中,Action 是框架的核心类,被称为业务逻辑控制器,主要用于实现对用户请求的处理。 一个 Action 类代表一次请求或调用,每个请求的动作都对应一个相应的 Action 类。也就是说,用户的每次请求,都会转到一个相应的 Action 类中...

吴声子夜歌的博客 1544

Struts2之Action类的三种编写方式

Action类的三种编写方式 Action 类就是一个pojo类 (Plain Ordinary Java Object)简单的java对象,没有继承某个类,没有实现接口,就是POJO类 Action类可以实现Action接口 Action接口中定义了5种视窗中常用的常量,常量的值对应的是5个逻辑视窗跳转页面(跳转的页面需要自己来配置),还定义了一个方法,execute方法 ** ER...

u011301372的博客 1024

struts2通配符及Action开发的三种方式

一,通配符与动态方法调用 1)准备一个UserAction.java,这个Action中有两个方法login()和register() package com.bighuan.a_config; import com.opensymphony.xwork2.ActionSupport; /** * @author bighuan */ public class UserAction ex

bighuan的博客 5215

Struts2:Action类的写法,推荐使用继承ActionSupport类的方法

新建包,action类,模块化的struts_demo2.xml的文件。先写一个action类,再写配置文件,再在 项目 运行。先写一个action类,再写配置文件,再在 项目 运行。

m0_75257168的博客 905

Struts2中Action详解

 在Struts2中Action部分,也就是Controller层采用了低侵入的方式。为什么这么说?这是因为在Struts2中action类并不需要继承任何的基类,或实现任何的接口,更没有与Servlet的API直接耦合。它通常更像一个普通的POJO(通常应该包含一个无参数的execute方法),而且可以在内容定义一系列的方法(无参方法),并可以通过配置的方式,把每一个方法都当作一个独立的acti

1874

Struts2之Action类概要

Struts2之Action(1)1、Action是应用的核心,Action类包含了对用户请求的处理逻辑。Action类也被称为 业务控制器 2、Action类是一个普通的POJO(传统的、普通的java对象,包含一个无参数的execute方法),无需继承任何基类或实现任何接口 3、Action来封装HTTP请求参数,包含于请求参数对应的实例变量,并提供对应的setter和getter方法。pu

Blank_Space 690

java struts action_Struts 2 实现Action的几种方式

Action用于处理用户的请求,因此也被称为业务控制器。每个Action类就是一个工作单元,Struts 2框架负责将用户的请求与相应的Action匹配,如果匹配成功,则调用该Action类对用户请求进行处理,而匹配规则需要在Struts 2的配置文件中声明。Struts 2框架下实现Action类有以下三种方式:普通的POJO类,该类通常包含一个无参数的execute()方法,返回值为字符串类型...

weixin_39575648的博客 310

Struts2中Action的传值方式

转载自:http://www.cnblogs.com/fmricky/archive/2010/05/20/1739734.html 1、字段驱动方式 所谓字段驱动方式就是通过字段进行数据传递。在Struts2中我们可以直接在Action里定义各种Java基本类型的字段,使这些字段与表单数据相对应,并利用这些字段进行数据传递。 第一篇中提到的登陆案例,用的就是字段驱动方式。

1435
上一篇: struts2框架的环境搭建以及简单使用入门
下一篇: Struts2配置Action的动态方法调用
Bran4220
博客等级 码龄9年 27粉丝 33原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值