Struts2入门之HelloWorld

Struts2入门之HelloWorld

1、下载Struts2

下载地址:http://struts.apache.org/
推荐使用struts-2.3.24,此版本较稳定。

2、新建Web项目

Struts2入门之HelloWorld

3、导入jar包

将下载的struts-2.3.24解压之后进入apps文件夹下,将里面后缀名为.war的文件复制一份,将其后缀名该为.zip。
Struts2入门之HelloWorld
对其解压,在WEB-INF\lib中可取得struts的13个常用jar包,将其复制到自己项目的lib文件夹中即可。
Struts2入门之HelloWorld

4、新建jsp页面

Struts2入门之HelloWorld
Struts2入门之HelloWorld
Struts2入门之HelloWorld

5、创建Action类

Struts2入门之HelloWorld
Struts2入门之HelloWorld

6、配置web.xml

配置struts自己定义的过滤器来处理请求。
此过滤器在struts的核心jar包中:
Struts2入门之HelloWorld
在web.xml中配置过滤器:
Struts2入门之HelloWorld

7、配置struts.xml

Struts2入门之HelloWorld

8、部署到tomcat

Struts2入门之HelloWorld
Struts2入门之HelloWorld

9、运行分析

Struts2入门之HelloWorld
Struts2入门之HelloWorld
敬请路过的大牛们,指点指正!!!