struts2面试题12010年07月10日 15:14Struts1与 Struts2的区别,它们常用到哪几个类, 以及工作流程?Struts1: ActionServlet[process()], RequestProcessor[processPreprocess()], PlugIn,Action, ActionForm, ActionForward,ActionMapping ,struts-config.xmlStruts2: FilterDispatcher, ActionSupport, ServletActionContext[getResponse()],ModelDriven[getModel()],MethodFilterInterceptorstruts.xml,它是在 WebWork 基础上发展起来的.Struts 工作流程:struts1:发布 Struts Web 服务时,根据 web.xml 初始化 ActionServlet,ActionContext 等内容.在接到一个 HttpRequest 请求后,ActionServlet 根据 struts-config.xml 中的配置内容,将请求的参数传到对应的 Formbean 中,并设置 session.然后根据请求中的 Action 参数,在 struts-config.xml中查找指定的 Action,并调用此 Action 来处理请求.根据 Action 的处理结果,会返回一个 forward变量,此时通过 mapping.findForward()查找出对应的 forward 所标示的 Action 或者 JSP 页面,将请求转到下一个处理.如果是 forward 指向 JSP 页面,则输出到前台.Struts2:(1)客户端提交一个 HttpServletRequest 请求(.action 或 JSP 页面)(2)请求被提交到一系列 Filter 过滤器,如 ActionCleanUp 和 FilterDispatcher 等(3)FilterDispatcher 是 Struts2控制器的核心,它通常是过滤器链中的最后一个过滤器(4)请求发到 FilterDispatcher 后,FilterDispatcher 询问 ActionMapper 是否需要调用某个 Action来处理这个 Request(一般根据 URL 后缀是否为.action 来判断)(5)如果 ActionMapper 决定需要调用某个 Action,FilterDispatcher 则把请求交到 ActioProxy,由其进行处理.(6)ActionProxy 通过 Configuration Manager(它会访问 struts.xml)询问框架的配置文件,找到需要调用的 Action 类.(7)ActionProxy 创建 一 个 ActionInvocation 实例 , 而 ActionInvocation 通过 代 理 模 式 调 用Action,(在调用之前会根据配置文件加载相关的所有 Interceptor 拦截器)(8)Action 执行完毕后,返回一个 result 字符串,此时再按相反的顺序通过 Interceptor 拦截器.(9) 最后 ActionInvocation 负责根据 struts.xml 中配置的 result 元素,找到与返回值对应的 result,决定进行下一步输出.?Struts1和 Struts2的区别和对...