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的环境配置


相关文章:

  • 2022-12-23
  • 2021-11-20
  • 2021-12-11
  • 2021-05-14
  • 2021-12-15
猜你喜欢
  • 2021-09-15
  • 2021-04-03
  • 2021-12-07
  • 2021-07-25
  • 2021-11-01
  • 2022-01-18
相关资源
相似解决方案