Recent spare time I have been Java Virtual Machine research, because the internship assigned to the project team inside, do not want to be so idle, and finally took the time to continue the topic of the post. I intend to put the part of the Java EE to the end, and then talk about the JVM and JavaScript, as long as the author has the latest learning notes summed up, will be taken to share with you in time. Sincerely hope that with the love of Java, close colleagues to progress together ...
This time we're going to go on to the last topic. Struts-2, a brief review of the history: over time, the changing requirements of the Web application framework produce several next-generation struts solutions. One of the struts Ti continues to adhere to the MVC pattern based on improvements to continue struts's successful experience.
The WebWork project, released in March 2002, revolutionized the struts framework and introduced a number of new ideas, concepts and functions, but not compatible with the original struts code. WebWork is a mature framework that has undergone several major improvements and releases. In December 2005, WebWork and Struts Ti decided to fight together, and at the same time, struts ti renamed the Struts Action Framework 2.0, to become the real next generation of struts.
Look at the Struts-2 process:
1 browser generates a request and submits a framework for processing: Depending on the configuration, which interceptors, action classes, and results are used.
2 request through a series of interceptors: according to the requested level of different interceptors do different processing. This is similar to the Requestprocessor class of Struts-1.
3 Invoke action: Produces a new action instance that invokes the business logic method.
4 the invocation produces the result: matches the results class and invokes the generated instance.
5 request to return through a series of interceptors: process can also be configured to reduce the number of interceptors
6 Request return User: Return servlet from Control, generate HTML.
The obvious point here is that there is no scope encapsulation of the Formbean, and you can get data directly from the action.
Here is a web.xml file with a Strut-2 configuration:
<filter>
<filter-name> controller </filter-name>
<filter-class> org.apache.struts.action2.dispatcher.FilterDispatcher </filter-class>
</filter>
<filter-mapping>
<filter-name> cotroller </filter-name>
<url-pattern> /* </url-pattern>
</filter-mapping>
Note that the previous servlet became Filter,actionservlet into a filterdispatcher,*.do/*.filter configuration defined names (for association) and filter classes. Filter mapping calls this filter with a URI that matches a successful request. By default, the extension is ". Action". This is "struts.action.extension" in the Default.properties file. attribute defined by the.
Default.properties is a property definition file that sets different property values by including a file named "Struts.properties" in the project Classpath path. The default profile name for Struts-2 is Struts.xml. Because the action extension for 1 and 2 is. Do and. Action, so it's convenient to coexist. Let's take another look at a Struts-2 action code:
public class MyAction {
public String execute()throws Exception {
//do the work return "success ";
}
}