Struts2 six years after the birth of the development, struts1 are already quite mature, but it is original in design flaws have been limited his development, for example, he can only inherit Action or dispatchAction inheritance is single inheritance. Action in the execute method does not debug struts1 This shows that is far too dependent on the servletAPI. In order to better development struts2 appeared, struts2 interceptors used to process customer requests, making controllers and servletAPI completely separate. Struts2 to use the core design patterns webwork achieved.
The status of the current web framework
struts2: simple and flexible web framework
Spring web framework: The most comprehensive web framework
Struts1: most resource-rich web framework
Tapestry: Components of the most perfect web framework
Jsf: closest to the web framework for asp.net
Struts2 with other web frameworks comparison
Struts1 vs struts2: struts1 inherited defects in a single action on the container's dependence expression language is incomplete, difficult to use, authentication type conversion error.
Struts2 vs jsf: jsf defect aop dependency injection to achieve, over-reliance on the container.
Struts2 vs spring web framework: the lack of the latter's tag library, type conversion issues.
Struts1 a detailed comparison with the struts2
Action Comparison: struts1 in the action could only be single inheritance, when this class inherits the class action after the other classes can not inherit, limiting expansion of inheritance class action. Struts2 in action interface can be seen, or inherit actionsupport class.
Thread compare: struts1 in action is a single case, meaning that when a user visits action only when it creates an action to handle the user's request, so also there will be a thread-safety issues, when multiple users simultaneous access to time , there will be resource consumption issues. Struts2 a good solution to this problem, it will be a visit to create an action, the thread does not appear, but also have a problem is that it will continue with action to create an instance of class kept occupied.
Servlet API: struts1 implements the servlet API exposed to the outside in a way, over-reliance on container servlet API. Struts2 do not rely on the container.
Get the object comparison: struts1 through actionform to get the value. Struts2 directly through the realization of the properties of the class action can access more convenient and direct.
Foreground language comparison: struts1 is jstl el. struts2 by ognl
Struts downloading and struts2 Download the zip file, unzip the folder after
Apps: struts2 examples of documents useful for beginners.
Lib: struts2 framework of the core jar package.
Src: includes struts2 of all the source code.
Docs: related documents, api documentation, Quick Start and so on.
J4: Let struts2 support jdk1.4 for jar package NOTE: struts2 right tomcate server requirements must be 5.5 or later.
Actual case development to prepare:
1. Copy the required jar package into the project, in the struts2 five in the core jar package: common-logging.jar ognl.jar, xwork.jar, struts2-core.jar, freemarker.jar
2. Struts.xml used to describe the action, is the core of the use of struts2.
Actual development to achieve a simple application of a simple project steps in struts2
1, will be ready just paste into the project jar package lib directory.
2, modify the web.xml file, configure the interceptor.
3, create a struts.xml file in src directory, as struts2 is the default in the src directory to read struts2.xml files, all file names and path is fixed.
4, create a class action to achieve Action interface, or inherit actionsupport class
5, modify struts.xml registered in the struts.xml file class action.
6, create a request for a visit.
* The annex is for the first example of a simple entry