(二)struts2.0之helloworld

2024-04-30 09:38
文章标签 helloworld struts2.0

本文主要是介绍(二)struts2.0之helloworld,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1.在导入包的最小集合   

commons-logging-1.0.4.jar   

freemarker-2.3.8.jar   

ognl-2.6.11.jar   

struts2-core-2.0.11.jar   

xwork-2.0.4.jar

 

2.在web.xml中编写过滤器

 
05.    <filter>  
06.        <filter-name>struts2</filter-name>         
07.        <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>   
08.    </filter>  
09.    <filter-mapping>  
10.        <filter-name>struts2</filter-name>  
11.        <url-pattern>/*</url-pattern>  
12.    </filter-mapping>  

 

3.编写action

     ⑴ 编写属性名

               每个属性对应表单域的name属性,生成对应的getter和sertter方法

               当表单提交到action时,会自动调用对应name的setter方法,sertter的调用在execute方法之前

               当使用<s:property value="name">,会调用name对应的getter方法;    

     ⑵重写execute方法

     ⑶最好继承ActionSupport类


4.编写struts.xml文件

       在src根目录下,编写struts.xml文件。为了方便,可以在struts开发包的根目录下apps中找到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><package name="struts2" extends="struts-default"><action name="msg" class="action.Msg"><result name="success">/msg.jsp</result></action></package>
</struts>



这篇关于(二)struts2.0之helloworld的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/948518

相关文章

Python简单入门教程helloworld

Python 学习资源 推荐书籍: Python核心编程(第二版) (强烈推荐,建议有一定基础的看,或者看完简明Python教程再看) Python 基础教程 第二版 (入门,没有核心编程好,但也不错) 编写高质量代码:改善Python程序的91个建议 (进阶,有一定基础再看) 书籍下载: Python 教程(部分内容来源于网络, 历时一年多总结整理的,给刚刚入门的

HelloWorld 模块

helloworld.c 代码 #include <linux/init.h>#include <linux/module.h>MODULE_LICENSE("Dual BSD/GPL");static int hello_init(void){printk(KERN_ALERT "Hello world\n");return 0;}static void hello_exit(v

ROS程序设计系列 - 5.实例helloworld

ROS程序设计系列 - 5.实例helloworld 1. 源由2. 步骤Step 1:安装ROS系统Step 2:创建框架工程Step 3:检查工程结构Step 4:创建CPP文件Step 5:修改配置文件Step 6:编译工程 3. 测试Step 1: 启动ROS CoreStep 2: 启动Hello程序 4. 总结5. 参考资料6. 补充 1. 源由 在做《Ardupil

使用命令行窗口新建一个Java文件,输出HelloWorld

进入桌面 cd desktop 在桌面新建文件夹 mkdir zwt 进入文件夹,新建.Java文件 cd zwtecho. > helloWorld.java 使用记事本打开文件编写代码 notepad HelloWorld.java 此时电脑就会自动打开文件,直接编写代码 public class HelloWorld(){public static void mi

myeclipse开发 spring+struts2.0+hibernate

各包作用: action与具体表单提交有关,是直接与前台交互的文件。一般一个功能对应一个actionaction之上是service,service为aciton提供各项基本功能,而action处理具体表单请求。比如service提供验证是否存在该用户函数isexistsuser,而action调用这个函数处理表单的请求。service之上是dao,到时直接对数据库表的操作,一般每个dao对应

Qwen-7B-Chat大模型安装训练推理-helloworld

初始大模型之helloworld编写 开发环境:modelscope GPU版本上测试的,GPU免费36小时 ps:可以不用conda直接用环境自带的python环境使用 魔搭社区 安装conda wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh 1.2 bash Minicond

Shiro HelloWorld (二)从数据库中获得数据

<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">1、创建users表,插入一条记录</span> <span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb

Shiro HelloWorld

Maven工程结构图如下: pom.xml中依赖如下: <span style="white-space:pre"> </span><dependencies><dependency><groupId>org.apache.shiro</groupId><artifactId>shiro-core</artifactId><version>1.2.4</version></de

Canvas(1)之HelloWorld

/*1.要使用canvas必须先设置其width和height属性2.接着获取绘制上下文,并指定能力,为2D还是3D3.绘制方式有填充和描边两种方式,即fillStyle 填充属性 fillRect()strokeStyle 描边属性 strokeRect()*/var drawing = document.getElementById('drawing');if(drawing

OrangePi AIpro 香橙派 昇腾 Ascend C算子开发 - HelloWorld

OrangePi AIpro 香橙派 昇腾 Ascend C算子开发 - HelloWorld flyfish Ascend C算子编程是SPMD(Single-Program Multiple-Data)编程 假设,从输入数据到输出数据需要经过3个阶段任务的处理(T1、T2、T3)。如下图所示,SPMD会启动一组进程,并行处理待处理的数据。对待处理数据切分,把切分后数据分片分发给不同进程处理