Struts2学习(二)【Struts2访问流程】
一、第一个示例的访问过程
我们之前创建了Struts2的第一个程序,SSH与SSM学习之Struts201,我们已经把它运行起来了,现在我们来分析一下它的过程。
访问过程说明:
当我们的服务器运行之后,我们在浏览器中 访问 http://localhost:8080/s2_1/test/TestDemo1Action。
这里面 我们的 namespace是 /test, 我们的Action的name是TestDemo1Action。我们的请求会经过Struts2的核心过滤器(我们在web.xml中配置了),核心过滤器就会去处理我们的请求。
核心过滤器就会去查找我们的主配置文件struts.xml,会去每个package下查找 namespace为/test的包。
查找到namespace为/test的包以后,接下来就会去查找 name 为 TestDemo1Action 的action。
查找到 name 为 TestDemo1Action 的action。查找到,这个aciton多对应的java类(class属性对应的javal类) com.qwm.struts2_1.testdemo.TestDemo1Action
运行 com.qwm.struts2_1.testdemo.TestDemo1Action 中的test1方法(配置是 method=”test1”)
运行结果放回到Aciton的 中
把结果转发到了 /hello.jsp中
浏览器显示 /hello.jsp的界面