Struts2 in Action 读书笔记(一)
一些基础性的东西: 1. Struts 2 sits on top of two important technologies. At the heart of all Struts2 applications lie the client/server exchanges of the HTTP protocol. The Java Servlet API exposes these lowlevel HTTP communications to the Java language.Although it’s possible to write web applications by directly coding against the Servlet API, this is generally not considered a good practice. Basically, Struts 2 uses the Servlet API so that you don’t have to. But while it’s a good idea to keep the Servlet API out of your Struts 2 code, it seems cavalier to enter into Struts 2 development without some idea of the underlying technologies. The next two sections provide concise descriptions of the more relevant aspects of HTTP and Java Servlets.它们的关系见附件图1。
?
2.Struts等框架都用到了HTTP协议 Most web applications run on top of HTTP. This protocol is a stateless series of client/server message exchanges. Normally, the client is a web browser and the server is a web or application server. The client initiates communication by sending a request for a specific resource. The resource can be a static HTML document that exists on the server’s local file system, or it can be a dynamically generated document with untold complexity behind its creation. 看来有空真的要看看《TCP/IP详解》
?
3.很重要的一个问题,什么是框架? A framework is a piece of structural software. We say structural because structure is perhaps a larger goal of the framework than any specific functional requirement. A framework tries to make generalizations about the common tasks and workflow of a specific domain. The framework then attempts to provide a platform upon which applications of that domain can be more quickly built. The framework does this primarily in two ways. First, the framework tries to automate all the tedious tasks of the domain. Second, the framework tries to introduce an elegant architectural solution to the common workflow of the domain in question.
?
4.为什么要使用框架? First, new developers will always have to learn the framework(你自己开发的框架) from the ground up. If you’re using a mainstream framework,there’s a trained work force waiting for you to hire them. Second, the in-house framework is unlikely to see elegant revisions that keep up with the pace of industry.In-house frameworks seem to be subject to architectural erosion as the years pass, and too many extensions are inelegantly tacked on.
?
5.拦截器的概念 Interceptors are Struts 2 components that execute both before and after the rest of the request processing. They provide an architectural component in which to define various workflow and cross-cutting tasks so that they can be easily reused as well as separated from other architectural concerns.
?
6.ValueStack的概念 Struts 2 uses the ValueStack as a storage area for all application domaindata that will be needed during the processing of a request. Data is moved to the ValueStack in preparation for request processing, it is manipulated there during action execution, and it is read from there when the results render their response pages.
?
7.OGNL的概念 OGNL is a powerful expression language (and more) that is used to referenceand manipulate properties on the ValueStack. 8.Two mechanisms for declaring your architecture Through XML-based configuration files or through Java annotations.
<action name="Login" )@Result(value="/RegistrationSuccess.jsp" )})
public class Login implements Action {
public String execute() {
//Business logic for login
}
}
?
我还是不会写读书笔记,感觉完全是书摘了.....