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)待续。。。》