JavaWeb development program

Java Web Development Technical Solution

Java Web development is divided into front-end and back-end:
Java Web front-end:
is what users can see and touch in Web applications. Including the structure of the Web page, the visual appearance of the Web and the interactive realization of the Web level.
—Front-end development mainly uses ajax / jQuery / js / html / css, etc., uses JS, uses JQuery / html / CSS, etc., to develop interactive effects.
Java Web backend:
—The backend is more interactive with the database to deal with The corresponding business logic. What needs to be considered is how to achieve functions, data access, platform stability and performance, etc.
-backend development mainly uses java / MySQL / Oracle, etc., using Java, SQL statement development.

Java web front-end development framework:
front-end engineering framework nodejs, React, router, react, redux, webpack

Java web backend development framework:
SSM & SSH: spring + springmvc / struts + spring jdbc / hibernate / mybatis, etc.

Most projects in the java backend are divided into three layers:
control layer (controller / action), business layer (service / manage), and persistence layer (dao).
The control layer
is responsible for receiving parameters, calling related business layers, encapsulating data, and routing to jsp pages. Then use various tags (jstl / el) or handwritten java (<% =%>) on the jsp page to display the data in the background
Business layer
Responsible for implementing business logic
Persistence layer
Data access and storage

Java web application operating mechanism:
Use tools such as maven or eclipse to pack your code into a war package, and publish this war package to the web container (tomcat / jboss / weblogic / websphere / jetty / resin) in your production environment .
After publishing, start your web container, start providing services, and then configure the domain name, dns, etc., the designed website can be accessed
1, enter your website domain name (www.xxx.com) in the browser, and then it happened what?
The browser routes to your service through ip, after tcp 3 handshake, starts to access your web server through tcp protocol, after
your web server gets the request, it starts to provide the service, receives the request, and then returns your response to it through response Browser

2. The above execution process is divided into two types in terms of implementation:
traditional Java web project development:
1. The client sends a request
2. The server's servlet or controller receives the request (routing rules are made by the back end, and the focus of the project development is on the back End, the web backend has a great weight, UI, frontend is only attached)
3, call service, dao code to complete business logic
4, return jsp
5, jsp show some dynamic code

New Java web project development method
1. The browser sends a request
2. Go directly to the html page (routing rules are formulated by the front end, the project development focus is moving forward)
3. The html page is responsible for calling the server interface to generate data (via ajax, etc. The background returns json format data)
4. Fill html, show dynamic effects, parse on the page and manipulate the DOM

Not just the front-end css, js so simple, front end, front-end project in the use of some of the framework and tools, open at project level, but also the need for front-end MVC framework, but also need to compile, package, deploy, is very complex,
more For large Internet companies, the more front-end projects are engineering projects, including version management, operation and maintenance of front-end projects.

Java web projects should avoid using jsp as much as possible. The more large and medium-sized web applications, the more decoupling the front-end and back-end, and playing with distributed architecture, such web application architecture is stronger:
normal distributed architecture is necessary. Disassembled:
web server cluster (nginx) + application server cluster (tomcat) + file server cluster + database server cluster + message queue cluster + cache cluster, etc.

The request steps of the new Java web project development method: a
large number of concurrent browser requests—> web server cluster (nginx) —> application server cluster (tomcat) —> file / database / cache / message queue server cluster
while playing sub-modules , Can also be split into small clusters according to business, encapsulate the core business into a business center, play remote business calls, play rpc, play soa, use springboot + Docker to play microservices, so that is a flexible distributed Architecture

Features:
1. Realize front-end and back-end decoupling, the front-end server uses nginx.
Front-end server put the css, js, images, and so on a series of static resources (can even put css, js, images and other resources into a specific file server, such as Ali cloud oss, and use the cdn acceleration),
front-end server Control page references, jumps, and call back-end interfaces. The
back-end server uses tomcat (think of the application server tomcat as a data provider) to speed up the overall response speed. However, the data cannot be brushed out
2. The Java web project development division of labor is clear:
front-end engineers: responsible for page logic, jump errors, browser compatibility issues, script errors, page styles and other issues.
Back-end engineer: Responsible for handling interface data errors, unsuccessful data submission, and response timeout.
3. In the case of large concurrency, the front-end and back-end servers can be expanded horizontally at the same time, by deploying server clusters. To reduce the concurrency pressure on the back-end server, all http requests except the interface are transferred to the front-end nginx.
The front-end framework solves functions such as page nesting, paging, and page jump control. The call interface is to call the method in the controller. If there are some permissions and other related verification on the page, then these related data can also pass ajax Take
4 from the interface. Perhaps you also need a WeChat-related light application, so that your interface can be shared completely. If there are app-related services, as long as some code is refactored, the interface can also be reused in large quantities to improve efficiency.
5. No matter how many things are displayed on the page, don't be afraid because they are loaded asynchronously

Technical solutions for front-end and back-end separation in Java Web development:
1. The front-end uses AngularJS to write SPA (Single Page Application) applications, and the back-end server only provides RESTful interfaces and is completely stateless.
Features:
Front and back are completely separated. Front-end developers do not need to care about what technology is used on the server side. They only need an interface description document.
Mobile app and PC site can share the same interface.
If there are too many "pages", the SPA application will load slightly slower for the first time.

2. Use NodeJS to render Web pages, and then call the back-end RESTful interface.
Features:
Complete separation before and after, back-end developers can focus on business logic development.
NodeJS code can easily hang up the process if the exception handling is not good.
Add a layer of NodeJS, increase the cost of network transmission, increase deployment and maintenance costs

Published 8 original articles · Likes2 · Visits 494

Guess you like

Origin blog.csdn.net/qq_42003546/article/details/102503068