Web final review exam points summary

foreword

I just reviewed web-related knowledge points to prepare for the final exam. I have just passed the final exam and shared the test points so that I can quickly review the concepts later. I hope the article can help everyone. Since it is a summary of the exam points, the knowledge The point is not comprehensive, I hope everyone understands.
References: Java Web Programming (Mooc Edition 2nd Edition) - Based on SSM (Spring+SpringMVC+MyBatis) Framework Chief Editors: Liang Yongxian, Chen Yingsheng, Yin
Xiaojun
Deputy Editors: Sang Yuan, Wang Lan, Zhang Junli

Chapter One

Web : The web is a set of all interlinked hypertexts distributed all over the world based on the HTTP communication protocol and stored in the web server.

Web development history : static document stage –> dynamic web page stage –> web2.0 stage

Technologies involved in the Web:

Client technology: HTML, CSS, Flash, client script technology

Technologies for server-side applications: CGI, ASP, PHP, ASP.NET, JSP

Chapter two

html : Hypertext Markup Language is an application under the Standard Universal Markup Language, and it is also a specification, a standard, which marks various parts of the web page to be displayed through markup symbols.

CSS : Cascading Style Sheets is a computer language used to express the style of documents such as HTML or XML.

**Dynamic web page technology: **In addition to the early CGI, the current mainstream dynamic web page technologies include JSP, ASP, PHP, Python, etc.

Markup tag form form:

Action attribute: used to specify the URL address of the program that processes the form data.

method attribute: used to specify the way data is transmitted to the server.

name attribute: specifies the name of the form.

onSublit attribute: The onSubmit attribute is used to specify the event that is triggered when the user clicks the submit button.

target attribute: Specifies the window in which the input data results are displayed.

CSS selectors : id selector, class selector, label selector

CSS rules : CSS includes 3 parts: selectors, attributes, and attribute values. The syntax format is: selector {attribute: attribute value;}

Selector: Also known as selector, all tags in HTML are controlled by different CSS selectors.

Attributes: mainly include font attributes, text attributes, background attributes, layout attributes, border attributes, list item attributes, table attributes, etc.

Attribute Value: A valid value for an attribute. Attributes and attribute values ​​are separated by :, and when there are multiple attributes, use ; to separate them.

How to add CSS to the page :

Inline style: Inline style is a relatively direct style, which is directly defined in HTML tags and implemented through the style attribute.

Embedded style sheet: An embedded style sheet is to use tags in the page to include CSS styles in the page.

Linked style sheet: Linking external CSS is a common way to reference style sheets. Defining CSS styles in a separate file and then referencing them in HTML pages is the most effective way to use CSS styles .

Ajax concept : Ajax is a combination of various existing technologies, which can realize the asynchronous request operation of the client, and then communicate with the server without refreshing the page, reduce the user's waiting event, reduce the burden on the server and bandwidth, and provide more Good service response.

Ajax principle : The user's operation on the page will communicate with the server through the Ajax engine, and then submit the returned result to the Ajax engine of the client page, and then the Ajax engine will decide to insert the data into the specified position of the page.

Chapter Four

Elements of jsp :

jsp script elements: statement, expression, script program

jsp instruction elements: page instruction, include instruction, taglib instruction

jsp动作指令:<jsp:include />、<jsp:forward />、<jsp:plugin />、<jsp:userBean />、<jsp:serProperty />、<jsp:getProperty />

jsp instruction :

page instruction : used to define the relevant attributes of the entire jsp page, these attributes will be converted into corresponding Java program codes when the jsp is parsed into a Servlet by the server.

Attributes of the page directive
extends attribute: This attribute is used to set the java class inherited by the jsp page. (uncommonly used)
Import attribute: This attribute is used to set the class package imported by jsp
pageEncoding attribute: This attribute is used to define the encoding format of the jsp page, that is, specify the file encoding.
contentYype attribute: This attribute is used to set the MIME type and character encoding of the jsp page.
Language attribute: This attribute is used to set the language used by the jsp page.

include directive : used for file inclusion. This directive can include the content of another file in a jsp page, but it only supports static inclusion.

taglib instruction : This instruction is used to load user-defined tags, and the tags loaded using this instruction can be used directly in jsp pages.

domain object :

page: scope: page, description: the Servlet class instance corresponding to the jsp page.

request: scope: request, description: Provides access to client HTTP request data.

session: scope: session, description: used to save the data that needs to be saved between the server and a client, when the client closes all the web pages of the website, the session variable will disappear automatically.

application: scope: application, description: application context, allowing jsp pages to share information with any web components included in the same application.

Description of built-in object scope :

page: The object can only be accessed in the jsp page that created it.

request: The object can be accessed in any jsp that is the same as the HTTP request that the jsp page that created it listens to.

session: The object can be accessed in any jsp that shares the same HTTP session as its jsp page.

application: The object can be accessed in any jsp that belongs to the same web application as the jsp page that created it.

Servlet concept : Servlet is a server-side program written in Java language. It acts as the middle layer between client requests and server responses. It belongs to the JavaEE middle-layer technology. It is called and executed by the server side. Return a response.

servlet configuration :

1. Declare the servlet object: In the web.xml file, declare a Servlet object through the label. There are two main sub-elements under this tag are and . Among them, the element is used to specify the name of the Servlet, which can be a custom name; the element is used to specify the complete location of the Servlet object, including the package name and class name of the Servlet object. Its declaration is as follows:

<web-app>      
    <servlet>
        <servlet-name>HelloWorld</servlet-name>
        <servlet-class>com.lyq.HelloWorld</servlet-class>
    </servlet>
</web-app>  

2. Mapping Servlet: After declaring the Servlet object in the web.xml file, you need to map the URL to access the Servlet. This action is configured using tags. The label contains two sub-elements named and . Among them, the element corresponds to the element in the label, and cannot be named arbitrarily; the element is used to map the access URL. It is configured as follows:

<servlet-mapping>
    <servlet-name>HelloWorld</servlet-name>
    <url-pattern>/HelloWorld</url-pattern>
</servlet-mapping>

servlet life cycle :

insert image description here

servlet method :

servlet method:
The service() method The service() method is the main method that performs the actual task. The Servlet container (that is, the Web server) calls the service() method to process the request from the client (browser) and writes the formatted response back to the client. Every time the server receives a Servlet request, the server will spawn a new thread and invoke the service. The service() method checks the HTTP request type (GET, POST, PUT, DELETE, etc.) and calls the doGet, doPost, doPut, doDelete, etc. methods when appropriate.
doGet() method A GET request from a normal request to a URL, or from an HTML form with no METHOD specified, is handled by the doGet() method.
doPost() Method A POST request from an HTML form that specifically specifies METHOD as POST is handled by the doPost() method.
destroy() method The destroy() method will only be called once, at the end of the Servlet life cycle. The destroy() method lets your servlet close database connections, stop background threads, write cookie lists or hit counters to disk, and perform other similar cleanup activities. After calling the destroy() method, the servlet object is marked for garbage collection.
init() method: The init method is designed to be called only once. It is called when the servlet is created for the first time, and it is not called for each subsequent user request. Therefore, it is used for one-time initialization, just like the Applet's init method. A servlet is created the first time a user invokes the URL corresponding to that servlet, but you can also specify that the servlet be loaded when the server first starts. When a user calls a Servlet, a Servlet instance will be created, and each user request will generate a new thread, which will be handed over to the doGet or doPost method when appropriate. The init() method simply creates or loads some data that will be used throughout the life of the servlet.

Chapter VII:

The concept of jdbc : jdbc is a technical standard for accessing databases. It is an application programming interface that can access databases through the java language. It consists of a set of classes and interfaces written in the java language. The jdbc API includes two packages java.sql and javax.sql.

Advantages and disadvantages of jdbc :

jdbc has the following advantages:

1. jdbc is very similar to odbc, which is easy for software developers to understand; 2. jdbc frees software developers from the complicated work of writing driver programs, and can fully focus on the development of business logic. 3. jdbc supports a variety of relational databases, which greatly increases the portability of software; 4. jdbc api is object-oriented, and software developers can re-encapsulate commonly used methods to improve code reusability.

jdbc has the following disadvantages :

1. The speed of accessing the database through jdbc will be affected to a certain extent; 2. Although the jdbc api is object-oriented, accessing the database through jdbc is still relation-oriented; 3. jdbc provides support for products from different manufacturers, which will Data sources have an impact.

There are five steps in database operation :

1. Load the JDBC driver

2. Create a database connection

3. Execute the SQL statement

4. Obtain query results

5. Close the connection

Chapter nine

MVC design pattern : MVC is a model that exists in the presentation layer of the server. In the MVC classic architecture, it is mandatory to separate the input, processing and output of the application, and divide the program into three core modules-model, view and controller.

1. Model: The model represents the core functions in the web application, including the business logic layer and the database access layer. In javaweb applications, the business logic layer is generally constructed by javabeans or ejbs. The data access layer is usually built using jdbc or hibernate, and is mainly responsible for dealing with the database.

2. View: The view mainly refers to the interface that the user sees and interacts with, that is, the appearance of the java web application. The view part is generally constructed by jsp and html. The view can receive user input, but it does not contain any actual business processing, it just passes the data to the controller. When the model changes, the view learns of the change and modifies its display through an agreement between the model and the view. For user input, the view forwards it to the controller for processing.

3. Controller: The controller is responsible for interacting and importing the data entered by the user into the model. In a java web application, when a user submits an html form. The controller accepts the request and calls the corresponding model component to process the request, and then calls the corresponding view to display the data returned by the model.

mvc architecture :

1. HTTP request: The client sends an HTTP request, and the web application server receives the request. If the request matches the request mapping path of DispatcherServlet, it forwards it to DispatcherServlet for processing.

2. Find the processor: After receiving the request, DispatcherServlet will find the processor to process the request according to the requested information and the configuration of HandlerMapping.

3. Call the processor: DispatcherServlet hands the request to the processor.

4. Call the model to process the business: the processor calls the service layer method to process the business logic.

5. Get the processing result: the processing result is ModelAndView.

6. Process view mapping: DispatcherServlet queries one or more ViewResoler view resolvers to find the view specified by ModelAndView.

7. Pass the model data to View for display.

8. HTTP response: display the result to the client.

insert image description here
Learn about configuration:

Filter configuration:

<filter>
  <filter-name>LogFilter</filter-name>
  <filter-class>com.runoob.test.LogFilter</filter-class>
  <init-param>
    <param-name>Site</param-name>
    <param-value>菜鸟教程</param-value>
  </init-param>
</filter>
<filter-mapping>
  <filter-name>LogFilter</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>

Spring's dao mode : data access object describes the role of dao in an application, which provides a way to read and write data in the database. External services are provided through interfaces, and other modules of the program access the database through these interfaces. The main role of DAO is to isolate persistence-related issues from general business rules and workflows. It introduces an interface for defining the persistence operations that the business layer can access, and hides the specific details of the implementation. The function of this interface will change depending on the persistence technology adopted, but the dao interface can basically remain the same.

What is ssm?
The SSM (Spring+SpringMVC+MyBatis) framework set is composed of two open source frameworks, Spring and MyBatis (SpringMVC is part of Spring), and is often used as a framework for web projects with simpler data sources.

Guess you like

Origin blog.csdn.net/qq_54162207/article/details/124703963