struts2的action方法匹配以及通配符的使用

【Bug已解决】codex file edit fails / Write operation denied — CodeX CLI 文件编辑失败解决方案 CodeX CLI 编辑文件时报写入被拒绝,本质是沙箱限制或权限不足。文中给出配置允许目录、修复权限、Git stash 管理冲突等完整方案。 阅读详情

1、 ActionMethod:Action执行的时候并不一定要执行execute方法,可以在配置文件中配置action的时候用“method”属性来指定执行哪个方法,也可以在url地址中动态指定(动态方法调用DMI)struts.xml文件的配置:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
    <constant name="struts.devMode" value="true" />
    <package name="user" extends="struts-default" namespace="/user">
        <action name="userAdd" class="com.bjsxt.struts2.user.action.UserAction" method="add">
            <result>/user_add_success.jsp</result>
        </action>
        <action name="user" class="com.bjsxt.struts2.user.action.UserAction">
            <result>/user_add_success.jsp</result>
            <result name="delete">/user_delete_success.jsp</result>
        </action>
    </package>
</struts>

 

index.jsp页面的内容:

<?xml version="1.0" encoding="GB18030" ?>
<%@ page language="java" contentType="text/html; charset=GB18030"
    pageEncoding="GB18030"%>
<% String context = request.getContextPath(); %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030" />
<title>Insert title here</title>
</head>
<body>
     <a href="<%=context %>/user/userAdd">添加用户</a><br />
     <a href="<%=context %>/user/user!add">添加用户</a><br />
     <a href="<%=context %>/user/user!delete">删除用户</a><br />
</body>
</html>

 

UserAction的内容:

package com.bjsxt.struts2.user.action;
import com.opensymphony.xwork2.ActionSupport;
public class UserAction extends ActionSupport {
     public String add() {
         return SUCCESS;
     }
     public String delete(){
         return "delete";
     }    
}

 

2、 使用通配符
strtus.xml文件的配置

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
    <constant name="struts.devMode" value="true" />
    <package name="actions" extends="struts-default" namespace="/actions">
        <action name="Student*" class="com.bjsxt.struts2.action.StudentAction" method="{1}">
            <result>/Student{1}_success.jsp</result>
        </action>
        
        <action name="*_*" class="com.bjsxt.struts2.action.{1}Action" method="{2}">
            <result>/{1}_{2}_success.jsp</result>
        </action>
    </package>
</struts>

 

Action的内容:

public class CourseAction extends ActionSupport {
     public String add() {
         return SUCCESS;
     }
     public String delete() {
         return SUCCESS;
     }
}
public class StudentAction extends ActionSupport {
     public String add() {
         return SUCCESS;
     }
     public String delete() {
         return SUCCESS;
     }
}
public class TeacherAction extends ActionSupport {
     public String add() {
         return SUCCESS;
     }
     public String delete() {
         return SUCCESS;
     }
}

 

  index.jsp页面的内容:

<?xml version="1.0" encoding="GB18030" ?>
<%@ page language="java" contentType="text/html; charset=GB18030"
     pageEncoding="GB18030"%>
<%String context = request.getContextPath();%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
     <head>
         <meta http-equiv="Content-Type" content="text/html; charset=GB18030" />
         <title>Insert title here</title>
     </head>
     <body>
         使用通配符,将配置量降到最低<br />
         <a href="<%=context%>/actions/Studentadd">添加学生</a>
         <a href="<%=context%>/actions/Studentdelete">删除学生</a><br />
         不过,一定要遵守"约定优于配置"的原则<br />
         <a href="<%=context%>/actions/Teacher_add">添加老师</a>
         <a href="<%=context%>/actions/Teacher_delete">删除老师</a>
         <a href="<%=context%>/actions/Course_add">添加课程</a>
         <a href="<%=context%>/actions/Course_delete">删除课程</a>
     </body>
</html>

 

相应的jsp页面有:
Course_add_seccess.jsp
Course_delete_success.jsp
Teacher_add_seccess.jsp
Teacher_delete_success.jsp
Studentadd_success.jsp
Studentdelete_success.jsp

 

http://blog.csdn.net/llbupt/article/details/6638078

多标签图像分类:标签依赖关系建模的最新论文解读与实战应用 多标签图像分类:标签依赖关系建模的最新论文解读与实战应用 ,人工智能,计算机视觉,大模型,AI,本文解读了最新相关论文,包括基于图神经网络(GCN)的ML-GCN方法,通过构建标签相关矩阵建模依赖关系;区域潜在语义依赖的RLSD模型,定位关键区域并利用RNN建模语义依赖;以及语义图表示学习的SSGRL框架,结合语义解耦与交互模块。通过实战应用,展示了基于PyTorch的ML-GCN模型实现,包括图像特征提取、标签依赖建模及训练评估流程,为多标签图像分类提供了有效解决方案。 阅读详情

相关推荐

超详细 | 贝叶斯网络基础——有图有真相

Hello,大家好,我是starz。这是本系列的第二篇《概率基础Ⅱ》,虽说是概率基础,但作为过渡,它开始以图为载体 这节的主要内容有: 贝叶斯网络 三种结构 D-划分 贝叶斯球 马尔科夫毯 应用例子 总结 让我们开始吧 :3 贝叶斯网络 概率图模型可笼统分为两类,一是基于无向图的马尔科夫网络: 二是基于有向图的贝叶斯...

qq_41603411的博客 2万+

Action使用通配符

定义< action>元素的name属性的时候使用通配符,使这个< action>元素不仅仅可以匹配一个URL,还可以匹配一类URL。而action的class属性和method属性能使用通配符的值。如果使用以下< action>配置:<action name="*_*" class="cn.javass.action.action.{1}Action" method="{2}">

chuang504321176的博客 598

用Python+LLM实现小说自动转剧本:从爬取到生成的完整实战指南(附GitHub源码)

本文提供了一份完整的实战指南,详细介绍了如何利用Python和大语言模型(LLM)构建一个自动化的小说转剧本工具。文章从网络爬虫获取文本开始,逐步讲解了使用LLM进行智能解析与结构化、集成专业模型进行情绪分析与动作生成,最终合成并输出格式规范的剧本文档。通过模块化架构设计和附带的GitHub源码,帮助开发者掌握从数据获取到内容生成的全流程,实现高效的小说剧本转换器。

xray4的博客 422

java strut2通配符_Struts2配置文件中使用通配符的方法(三种形式)

Struts2简介Struts2是一个基于MVC设计模式的Web应用框架,它本质上相当于一个servlet,在MVC设计模式中,Struts2作为控制器(Controller)来建立模型与视图的数据交互。Struts 2是Struts的下一代产品,是在 struts 1和WebWork的技术基础上进行了合并的全新的Struts 2框架。其全新的Struts 2的体系结构与Struts 1的体系结构...

weixin_28956181的博客 201

让 AI 学会“慢思考”:MCP Sequential Thinking 深度部署与使用指南

摘要: MCP Sequential Thinking 是一种让AI具备"慢思考"能力的技术,通过动态调整思维路径解决复杂问题。本文详细介绍了在Windows、macOS和Linux系统下的部署方法,包括环境准备、配置文件修改等步骤。该技术通过"产生想法-评估需求-修正路径"的循环机制,显著提升AI在代码设计、数学证明等复杂任务中的表现。文章还提供了验证安装方法、使用示例和常见问题解答,帮助开发者解锁AI的深层思考能力。(149字)

weixin_43236925的博客 1927

特征图与token的区别以及两者之间的转换

特征图和token之间的联系以及两者之间的转换

mariodf的博客 1017

Struts 之 通配符 路径匹配 常量用法 配置默认值

Struts 框架学习 Action的开发的几种方式 方式1 : 继承ActionSupport 如果使用Struts校验功能,必须继承此类 方式2 : 实现Action接口 方式3 :不继承任何类,不实现任何接口 1、通配符:   在Struts中配置信息,可以用*与{1} 可以优化配置 public class UserAction { private ...

weixin_30699741的博客 155

labview的TDMS文件读写

本文先介绍TDMS概念和文件结构,然后介绍VI如何使用,最后分析一个labview的自带范例

观则明的博客 1万+

struts2.5框架使用通配符指定方法

Struts has detected an unhandled exception: Message: There is no Action mapped for namespace [/] and action name [user_login] associated with context path [/Struts2_exec_PM].

小小Lim的Code世界 610

一文搞定3D卷积

在讨论卷积核的时候,是不把channel维加进去的 核 = 一个可以滑动的窗口 窗口内不同位置数据之间的权值共享 3D卷积,卷积核会在3个方向上运动,那么卷积核的运动需要有三个自由度(一小块立方体,在一个大面包块内3个方向上滑动 2D卷积,卷积核只在2个方向上运动,因此只有两个自由度(一小片纸,在一大张纸内2个方向上滑动 1D卷积,卷积核只在1个方向上运动,因此只有一个自由度(一条滑窗,在一大长线上1个方向上滑动 一个卷积核运算一次 得到一个输出值 以上讨论了单个卷积核,接下来考虑多通道,一个卷积核对应一

njuptalex的博客 3万+

Dify 本地插件安装失败?别慌,这篇教程手把手教你解决(解决 the plugin you want to install has a bad signature 报错的问题)

🤯dify安装本地插件报错 PluginDaemonBadRequestError: plugin verification has been enabled, and the plugin you want to install has a bad signature。的解决方案!

XiaoqiangClub的博客 3996

struts2动态方法调用和通配符配置

struts2默认一个action需要继承ActionSupport并提供默认execute方法,在struts.xml文件中需要配置action对应的类和返回结果页面。随着开发的进行,请求会越来越多,这样我们的action会越来越多,而且在struts.xml中的配置也会越来越多,这么繁琐的编码和配置,肯定不是struts2的初衷。当然有可以解决这种多请求的办法。我们可以在一个action总定义...

feinifi的博客 3128

Vue - 最新详细实现滑块拖动拼图验证,网站登录验证滑块验证功能,拖动滑块到图片缺口的位置即为成功,滑块验证安全检测(详细示例代码,一键复制运行)

您一定见过很多系统都“配备”了滑块验证、拼图验证、找不同等,本质上都是为了验证登录系统的是人还是机器(代码),如下图所示效果: 您打开项目根目录,终端执行如下命令:拼图式拖动滑块验证 验证拖动滑块验证,滑动拼图/图片点选验证 接下来,在中加入以下代码: 如下图所示: 更多配置示例和参数详见官方文档,以下便是如上效果图的代码:.........

🏆 前端领域优质创作者 1万+

2、struts2开发action 的三种方法以及通配符、路径匹配原则、常量

struct2 开发action 的三种方法1、继承ActionSupportpublic class UserAction extends ActionSupport { // Action中业务处理方法 public String login() { System.out.println("UserAction.login()"); // return "

yungcs的专栏 5946

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

深度学习工具包 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、继承ActionSupport public class UserAction extends ActionSupport { // Action中业务处理方法 public String login() { System.out.println("UserAction.login()"); // ...

weixin_34381666的博客 135

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

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

struts2 通配符

注意:命名规则     注意如果有通配符,先精确匹配action的name属性,如果不能精确匹配,再进行通配,(只要action配置中有通配符所有有通配符根据配置先后进行匹配) --> Eg1: package name="tpf" namespace="/tpf"extends="struts-default" >     <!-- 通配符 -->         acti

u012603040的专栏 916

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

Strut2.5使用通配符的方法访问action

Strut2.5使用通配符的方法访问action,要在struts.xml的配置文件中添加如下代码 <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN" "htt...

elsostal的博客 261

Struts2使用通配符完成方法和action的调用

官网对struts2通配符使用的介绍: Wildcard Mappings <actionname="*_*"class="com.netshuai.action.{1}Action"method="{2}"><resultname="success">/{2}_{1}Success.jsp</result></action> 如上...

weixin_30507481的博客 204

【struts2】action中使用通配符

在以前的学习中,元素的配置,都是用明确的配置,其name、class等属性都是一个明确的值。其实Struts2还支持class属性和method属性使用来自name属性的通配符。   1)接下来看看使用通配符的示例,如果我们使用以下配置: action name="*_*" class="cn.javass.action.action.{1}Action" method="{2}">

z69183787的专栏 1416

java strut2通配符_Struts2的通配符配置方式

Struts2的Action类很有意思,你可以使用3种方式来实现具体的Action类:让你的Action类继承自ActionSupport类(项目中最常用这种方式,因为ActionSupport类中定义了很多帮助方法)让你的Action类实现Action接口使用POJO的方式来实现,只要Action类中有一个返回值为String的execute方法就好了(这种方式使Action类最容易被测试)以上...

weixin_36297381的博客 191

Struts2用通配符配多个action方法

 使用通配符映射(wildcard mappings)方式:在struts.xml文件中配置元素时,它的name、class、method属性都可支持通配符,这种通配符的方式是另一种形式的动态方法调用。当我们使用通配符定义Action的name属性时,相当于用一个元素action定义了多个逻辑Action: /success.jsp /error.j

del1214的专栏 2580
上一篇: struts2 基础学习
下一篇: Java中的static
itommy2016
博客等级 码龄11年 42粉丝 493原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值