1) First major difference between Jakarta Struts 1 and Struts 2 framework is in Action class itself. In Struts 1 it's mandatory to extend org.apache.struts.action.Action and implement execute() method which returns ActionForward and accept HttpServletRequest and HttpServletResponse. This is not the case with Struts 2, here Action class can be a simple POJO or Java object with execute() method. Also execute() method returns String rather than returning ActionForward object. You can still use ActionSupport class or Action interface but those are completely optional.
2) Second main difference between Struts 1 and Struts 2 is on configuration files, earlier we used to configure Struts using struts-config.xml, but with Struts 2 you can use multiple configuration file, most commonly used as struts.xml.
2) Second main difference between Struts 1 and Struts 2 is on configuration files, earlier we used to configure Struts using struts-config.xml, but with Struts 2 you can use multiple configuration file, most commonly used as struts.xml.
3) One more difference between Struts 1 and Struts 2 is on Front end Controller. In Struts 1, ActionServlet is considered as FrontController while in Struts 2 its Filter, which can be considered as front end controller.
4) Another useful enhancement in Struts2 is Interceptor API, which allows to do lot of stuff much easily e.g. file upload using Struts2's builtin FileUploadInterceptor class.
5) One more difference between Struts 1 and Struts 2 which I like is removing dependency of Action classes to Servlet API in form of HttpServletRequest and HttpServletResponse classes required in execute() method. Struts 2 don't have such dependency and its execute() method doesn't required Servlet API.
No comments:
Post a Comment