eclipse中Strut2的环境配置

Strut2搭建步骤:
1、导包
2、编写Action类
3、配置struts.xml文件
4、在web.xml中部署struts2的核心过滤器

1、导包
使用struts需要引入13个jar包
eclipse中Strut2的环境配置

jar包从apps/struts2-blank.war解压得来

2、编写Action类(action类是struts2的核心类)

eclipse中Strut2的环境配置

3、配置src/struts.xml文件

eclipse中Strut2的环境配置

4、在web.xml中部署struts2的核心过滤器
核心过滤器完整类名:org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
eclipse中Strut2的环境配置

5、测试
根据以上的配置,访问的地址为:http://localhost:8080/StrutsDemo/first/firstAction
StrutsDemo:你的工程名
first:package的namespace属性
firstAction:action的name属性
先在控制台打印"hello struts2"

eclipse中Strut2的环境配置

再显示first.jsp页面(因为是转发,所以url不变)
eclipse中Strut2的环境配置