從web.xml部署文件的配置可以看出StrutsPrepareAndExecuteFilter時一切action請求的必經之類。
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
此係列文章通過struts2的源碼,學習struts2的運行過程與原理。一切根源從核心過濾器StrutsPrepareAndExecuteFilter開始。
(當每次啓動服務器的時候第一次請求都會調用該類的init方法,隨後的請求會調用doFilter。)
此係列文章將按照 init()->doFilter()->destroy() 的順序進行學習。
目錄
- init()
- doFilter()
- destroy()
未完,待更新。