java struts2 数据走向
第一 过滤器
FilterDispatcher是strusts2的一个核心过滤器,filter,接受所有的客户端的请求,讲过一系列的处理才会到达action,对filter 首先是init方法的初始化
代码段:
public void init(filterconfig filterconfig){
try{
//获取web.xml的filter内的init-param参数配置
this.filterconfig=filterconfig;
initlogging();
//初始化日志
dispatcher = createdispatcher(filterConfig);
dispatcher.init();
}
}
init 的主要工作是创建建并初始化dispatcher,分发器里面涉及到很多的操作,比如加载配置,创建内部容器,以至创建objectFactory,创建以及调度Action等等,都是dispatcher中完成的,所以要关注
struts2 也有依赖注入功能,普通的开发人员使用到注入功能,需要把用到的依赖注入功能的类在配置文件中使用<bean>标签配置才能生效
在web,.xml配置在filter标签里面的参数需要配置]
struts2 对配置文件的加载顺序
1,org/apache/struts2/default.properties
该文件配置的是struts2的常量的默认值,比如:struts.i18n.encoding,struts.action.extension
2,struts-default.xml,该文件配置struts2的核心bean,以及用constant配置的常量,比如,objectfactory,actionproxyfactory,actionmapper的bean
3,struts.xml是使用struts2时的基本配置,比如action,result,intereptor,constant