struts2学习 action 2

struts2 执行流程:

用户于浏览器敲入访问的地址 ---> 浏览器将请求发送给服务器 --->服务器判断交给哪个web应用来处理。

读取web.xml 配置

<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类。

org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter调用doFilter()方法。

在方法中读struts-xml文件。

根据用户请求的地址,找到package,action.result.然后返回相应的页面给浏览器。

 

 

 

原文地址:https://www.cnblogs.com/bukudekong/p/2437301.html