struts2执行流程分析

 

1、开源框架查看源码某些方法看不到原因?

版本不对应。

es:xwork-core-2.1.6.jar的源码必须对应的是2.1.6以上的版本

2、struts2如何实例化action?如何利用set方法灌入action的属性?

一、action请求处理流程:

(

心得:

**正向单步跟踪经常进入接口,可采用反向跟踪:试着找到最底层的实现类的方法,在那添加断点向前找调用过程,相当明了。

**出现跟踪到的类为红字不存在形式原因:表明在build path下没有该jar包(es:它是tomcat/lib下的jar包,解决办法是将tomcat/lib下**的jar包引入即可,记住一定是tomcat/lib下的jar)。

**出现的是class文件形式原因:说明没有引入源文件。

**tomcat如何找到filter执行dofilter()方法的原理,姑且先不去了解。

)

-->(1.在web.xml中找到struts2处理action的filter,即FilterDispatcher

-->(2.org.apache.struts2.dispatcher.FilterDispatcher.doFilter(ServletRequest req, ServletResponse res, FilterChain chain)

-->(3.org.apache.struts2.dispatcher.Dispatcher.serviceAction(HttpServletRequest request, HttpServletResponse response, ServletContext context, ActionMapping mapping)

《**3、4、5步解释:其实在serviceAction里调用的是StrutsActionProxyFactory extends DefaultActionProxyFactory对象的createActionProxy(String参数开头、六个参数),但StrutsActionProxyFactory 没有覆写》

createActionProxy(String参数开头、六个参数)这个方法,所以只能调用父类DefaultActionProxyFactory对象的createActionProxy(String参数开头、六个参数),又由于此方法中调用了createActionProxy(ActionInvocation参数开头、六个参数)的方法,同时StrutsActionProxyFactory把该方法覆写了,所以还要执行StrutsActionProxyFactory.createActionProxy(ActionInvocation参数开头、六个参数)方法》

-->(4.com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(String namespace, String actionName, String methodName, Map<String, Object> extraContext, boolean executeResult, boolean cleanupContext)

-->(5.org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(ActionInvocation inv, String namespace, String actionName, String methodName, boolean executeResult, boolean cleanupContext)

-->(6.org.apache.struts2.impl.StrutsActionProxy.prepare()

-->(7.com.opensymphony.xwork2.DefaultActionProxy.prepare()

-->(8.com.opensymphony.xwork2.DefaultActionInvocation.init(ActionProxy proxy)

-->(9.com.opensymphony.xwork2.DefaultActionInvocation.createAction(Map<String, Object> contextMap)

-->(10.com.opensymphony.xwork2.ObjectFactory.buildAction(String actionName, String namespace, ActionConfig config, Map<String, Object> extraContext)

-->(11.com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(String beanName, Map<String, Object> extraContext, boolean injectInternal)

-->(12.com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(Class clazz, Map<String, Object> extraContext)《该方法中的else体中的action属性值注入过程还没弄明白呢?待续。。。》

-->(13、1.autoWiringFactory.autowire(clazz, AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, false);只是将action实例化,而不去管action的属性值;

-->(13、2.com.opensymphony.xwork2.spring.SpringObjectFactory.autoWireBean(Object bean, AutowireCapableBeanFactory autoWiringFactory);负责action的属性(指Spring的xml文件中配置的bean)赋值;而view层的--传过来的参数值赋到action属性上是在拦截器里进行的;

-->(14.---接(13、2.---org.springframework.beans.factory.support.

AbstractAutowireCapableBeanFactory.autowireBeanProperties(Object existingBean, int autowireMode, boolean dependencyCheck)待续。。。》

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值