其实用最简单的七个步骤:
1:客户端在浏览器中输入一个url地址;
http://localhost:8080/gqxx
2:这个url请求通过http协议发送给tomcat;
http://localhost:8080/gqxx/IndexAction_welcome
3:tomcat根据url找到对应项目里面的web.xml文件;
4:在web.xml里面会发现有struts2的配置;
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
5:然后会找到struts2对应的struts.xml配置文件;
6:根据url解析struts.xml配置文件就会找到对应的Action class;
7:调用完class返回一个结果result,根据struts.xml返回到对应的jsp;
8:jsp页面再发出另一个请求,只是跳转页面的请求,超链接
http://localhost:8080/gqxx/isLogin_AdminAction
9:前台页面跳转,后台数据处理。
10:在action里面定义一个user对象,然后写上对应的Setters和Getters方法获取
- 1
- 2
- 3
- 4
- 5