Struts from 1.1 to 1.3 have been used for many years, have risen to 2, but a big face, must be re-examined. Learn from scratch and take notes in order to point.
1. Struts2 and Struts1 seem to have no blood relationship, Cheng from webwork, direct harm webwork no longer launch a new version, the original webwork users only need to shun it, that is, the channel into the canal; the opposite Struts1 development experience for STRUTS2 but not There's too much help.
2. Struts1 's core controller is Actionservlet, and Struts2 's core controller is filterdispatcher. STRUTS2 's business action generates an action agent at run time.
3. The Struts1 action must inherit the abstract action class, invade the Servlet API, and the STRUTS2 action can be implemented Actionsupport, or as long as a pure POJO to act, completely with the servlet Margin. So that the test of Struts2 than Struts1 strong, can put Struts TestCase thrown aside.
4. Struts1 at run time an action will only generate an instance, and the action in STRUTS2 should generate a new instance of each request, and STRUTS1 should be more concerned with the thread security.
5. Struts1 relies on Actionform to accept data, which is also dependent on the Servlet API, not the ordinary JavaBean, and STRUTS2 can get the requested attribute in the Action attribute and, of course, can be encapsulated in an independent POJO. But to remind, in Struts1.3 also can use POJO to accept request attribute, but use up a bit cumbersome.
6. Struts2 uses a new OGNL expression language that can access the value stack and is more powerful in support of collections and indexed properties.
7. Struts1 configuration files require only struts-config.xml;struts2 configuration files to have Struts.xml and struts.properties. Struts.properties has two struts.devmode = Fase and Struts.configuration.xml.reload = True is very cute, set the current development or production mode, and Struts.xml change Whether the automatic reload after the change, eliminates the need to manually restart the application of the necessary steps.
8. Struts2action's Execute () has no parameters, returns a string, unlike the Struts1 Action's execute () has a big string and does not say, just returns Actionforward, lets this Action and Struts1 take off is not the relationship, or Struts2 come smart, only return the String, anyway, the name, and suddenly this Action also became POJO, reusability enhanced, no wonder there is a special book, called "POJO in action."
9. Struts1 View only support JSP, this is not to blame it, only the origin is too early, then only JSP a performance layer. Compared with the Struts2, the laid can be close to the Freemarker, Velocity, XSLT, PDF and other view technologies.
STRUTS2 provides a powerful and complex tag library that is unified as an "s" prefix. and adapt to the trend of the times to join the support of AJAX. It also provides a more user-friendly authentication feature.