Difference Betwixt Struts One Together With Struts Two Spider Web Evolution Framework
Monday, February 11, 2019
Add Comment
I had function previously on Struts 1 but never touched Struts 2, particularly since Spring MVC was at that topographic point to bring the leading role. Recently i of my friend inquire me to assistance alongside Struts2, which leads me to await on Struts2 framework from start. First affair I wanted to abide by out differences betwixt Struts 1 in addition to Struts 2 framework, because inwards my experience, if y'all receive got worked inwards previous version looking differences betwixt ii versions of Struts tin speedily assistance to find, what changes in addition to What are the novel features, concepts in addition to improvement is offered yesteryear Struts 2. Also difference betwixt Struts 1 in addition to Struts 2 is a practiced candidate to include in my listing of Struts interview question for quick revision. To my surprise, Struts 2 seems to hold upward completely dissimilar than Struts 1 framework, because closed to of the nigh familiar materials similar ActionForm, struts-config.xml, in addition to Action classes are changed inwards Struts 2 framework. Struts 2 has likewise done practiced undertaking on removing instantly dependency of Action classes on Servlet API e.g. HttpServletRequest in addition to HttpServletResponse, which makes testing slow yesteryear using Dependency Injection concept. In this article, nosotros volition closed to of import differences betwixt Struts 1 in addition to Struts 2 framework.
Struts 1 vs Struts 2 - Differences
Here is my listing of closed to mutual departure betwixt Struts 1 in addition to Struts 2 framework. This listing contains closed to observations, which tin likewise assistance y'all to estimate closed to major changes inwards struts 2 from struts 1.
1) First major departure betwixt Jakarta Struts 1 in addition to Struts 2 framework is inwards Action cast itself. In Struts 1 it's mandatory to extend org.apache.struts.action.Action and implement execute() method which returns ActionForward in addition to bring HttpServletRequest in addition to HttpServletResponse. This is non the illustration alongside Struts 2, hither Action cast tin hold upward a unproblematic POJO or Java object alongside execute() method. Also execute() method returns String rather than returning ActionForward object. You tin even thence utilization ActionSupport cast or Action interface but those are completely optional.
2) Second top dog departure betwixt Struts 1 in addition to Struts 2 is on configuration files, before nosotros used to configure Struts using struts-config.xml, but alongside Struts 2 y'all tin utilization multiple configuration file, nigh usually used equally struts.xml. What is to a greater extent than of import is announcement of Struts 2 Filter in web.xml e.g.
<filter>
<filter-name>struts2Fitler</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2Fitler</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Also, if y'all notice, instead of mapping this to *.do or *.action nosotros receive got mapped it alongside *, which agency all url designing volition hold upward flown to struts2 filter.
3) One to a greater extent than departure I noticed betwixt Struts 1 in addition to Struts 2 is on Front terminate Controller. In Struts 1, ActionServlet is considered equally FrontController acre inwards Struts 2 its Filter, which tin hold upward considered equally forepart terminate controller.
4) Another useful enhancement inwards Struts2 is Interceptor API, which allows to do lot of materials much easily e.g. file upload using Struts2's builtin FileUploadInterceptor class.
5) One to a greater extent than departure betwixt Struts 1 in addition to Struts 2 which I similar is removing dependency of Action classes to Servlet API inwards cast of HttpServletRequest in addition to HttpServletResponse classes required inwards execute() method. Struts 2 don't receive got such dependency in addition to its execute() method doesn't required Servlet API.
There are lot to a greater extent than departure inwards Struts 1 in addition to Struts 2 in addition to I advise going thorough Struts 2 documentation equally y'all larn Struts 2. To me, Struts 2 looks completely dissimilar than Struts 1. Since I am using Spring MVC to a greater extent than frequently, I even thence demand to explore Struts 2 to a greater extent than closely. I volition continue this listing of differences betwixt Struts 1 in addition to Struts 2 updated equally in addition to when I constitute closed to to a greater extent than differences.
Further Learning
How to configure LDAP authentication alongside Windows Active Directory using Spring Security
0 Response to "Difference Betwixt Struts One Together With Struts Two Spider Web Evolution Framework"
Post a Comment