0
点赞
收藏
分享

微信扫一扫

Struts2流程图


  1. tomcat启动 加载web.xml(配置有过滤器)

<?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>

  1. tomcat实例初始化过滤器
  2. struts2.xml被加载

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
<package name="p1" extends="struts-default">
<action name="hello" class="org.ccit.com.web.action.HelloAction" method="sayhello">
<result name="success">/success.jsp</result>
</action>
</package>
</struts>

  1. 客户端发出请求 index.action
  2. 请求被过滤器拦截 并从struts2.xml中查找action
  3. 找到后 实例化action 调用对应方法 根据方法返回值 确定结果视图
  4. 找到jsp页面 响应浏览器
  5. Struts2流程图_struts2


举报

相关推荐

0 条评论