Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the concepts of springMVC and spring

2025-03-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Most people do not understand the knowledge points of this article "what are the concepts of springMVC and spring", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this article "what are the concepts of springMVC and spring?"

What is springMVCspringMVC is a framework based on the MVC architecture to simplify WEB applications; a framework that belongs to the presentation layer. How springMVC works: the user sends a request to the front-end controller, which receives the request to call the processor mapper, which finds the specific processor according to the requested URL, and generates the processor object and the processor interceptor (if any) back to the front-end controller. The front-end controller invokes the processor through the processor adapter and then executes the controller. After execution, the view and model are returned, and the processor adapter returns the controller execution result view and model to the front-end controller. The front-end controller passes the view and model to the view parser, and returns the specific view after parsing. The front-end controller renders the view (that is, filling the model data into the view), and the front-end controller responds to the user. SpringMVC understands that the entrance to springMVC is a servlet, the front-end controller. SpringMVC is based on method development (one URL for one method), and the request parameters are passed to the formal parameters of the method, which can be designed as singleton mode or multiple cases. It is recommended to use singleton, and the default is singleton. Why is a single case recommended? 1. Performance (you don't have to New objects for every request). 2. Multiple examples are not required (do not define member variables in the controller). What is the spring framework it is a lightweight open source framework to create good performance, easy to test, reusable code; it is based on IOC (reverse control) and AOP (aspect-oriented) architecture multi-tier Jzee (enterprise application) system framework. Advantages: 1. Be able to organize middle-tier objects effectively, regardless of whether EJB (Enterprise JavaBean) is used. 2. It eliminates the excessive use of singleton pattern in work, and reduces the testability and object-oriented of the system. 3. Eliminate the need for property files in various custom formats and make it easy for unit testing. 4. Reduce the code for programming interfaces rather than classes, and develop good programming habits. 5. Use it to create applications that rely as little as possible on its (APIS) programming interface. Spring's understanding of its two cores: IOC (inversion of control) and AOP (aspect-oriented). 1. IOC: reduces the coupling degree of the program and makes the project a pluggable component project. 2. AOP: release the energy of the development process, focus more on solving customer needs, and have high maintainability. 3. The transaction management mechanism it provides uses the declarative way to configure the transaction, so that there is no need to change the source code during maintenance, which solves the problem of program hard coding. 4. The DAO (data access object) template it provides makes the persistence layer have one more use. 5. It can integrate any current framework to make it clearer when managing projects. There are two ways for spring to manage transactions. 1. Programmatic transactions are hard-coded in the code. 2, declarative transactions, configured in the configuration file; (recommended) declarative transactions are divided into two types: 1, declarative transactions based on XML. 2. Declarative transactions based on annotations. What is dependency injection? dependency injection is an idea to achieve control inversion (the other is dependency lookup). In the process of development, when we need an instance of a class, it is for the user to provide us with an instance of the class, rather than to obtain it. There are two ways to achieve dependency injection: 1. Use constructor injection. 2. Set method injection. What is the inversion of control IOC is one of the core of spring. Control inversion means that when we acquire an object, we change from the previous initiative to passive reception; that is to say, when programming a class, we only need to provide a class member of an interface type, and we do not need a specific implementation class. it is provided by the user when using, which reduces the coupling between the class and the class. MyBatisMyBatis is an excellent persistence framework that supports normal SQL queries, stored procedures, and advanced mappings. Almost all manual settings of JDBC (Java database connection) codes and parameters and retrieval encapsulation of result sets are eliminated. You can use simple XML or annotations for configuration and raw mapping to map interfaces and Java's POJO (plain Java objects) to records in the database. How MyBatis works

What is the new framework of springBoot provided by the pivotal team to simplify the initialization and development process of new spring applications. The framework is configured in a specific way so that developers do not need to define a templated configuration. SpringBoot component 1, springBoot autoconfiguration: spring startup can detect the availability of certain frameworks, and once the framework is detected, it automatically configures it. 2. SpringBoot Core: it is the basis of other spring models, and it provides some functions that can be done by yourself through verification. 3. SpringBoot starters: helps start the project, which automatically adds startup projects and dependencies. SpringBoot features 1, used to achieve micro services 2, automatic configuration 3, custom configuration 4, modular 5, independent packaging, direct operation 6, embedded servers (such as: Tomcat server) 7, spring Cloud's basic spring Security security framework spring Security is a powerful and highly customizable authentication and access control framework. It is the practical standard for ensuring the security of spring-based applications. Main functions: 1, authentication: verify whether the user name and password are legal (whether users in the system) 2, authorization: the system user does not mean that you can use certain functions, because you do not have permissions for 3, defense session fixed, click hijack Attacks such as cross-site request forgery 4, servlet API integration 5, optional integration with springWebMVC Java multithreading, collection, happy / pessimistic lock what is multithreading multiple threads can be opened in a process, and each thread can perform different tasks in parallel (simultaneously). Such as: process A workshop, thread A workshop workers; multithreading technology can improve the efficiency of program execution, multithreading is a concurrent means, is a special form of multitasking, but multithreading uses less resource overhead. There are three ways to create threads: 1, implement Runnable interface 2, inherit Thread class itself 3, create thread multithread through Callable and Fature principle 1, CPU can only handle one thread at a time, only one thread is working (executing) 2, multithread concurrent (simultaneous) execution In fact, it is CPU that quickly switches directly among multiple threads. 3. If CPU schedules threads fast enough, it creates the illusion of multi-thread concurrent execution. What happens if there are too many threads? 1. CPU will switch between N multithreads, and CPU will be exhausted. Consume a lot of CPU resources 2, thread execution efficiency reduces thread life cycle 1, new state 2, ready state 3, running state 4, blocking state: 1, waiting blocking 2, synchronous blocking 3, other blocking 5, Several main concepts of dead state threads: 1, thread synchronization 2, inter-thread communication 3, thread deadlock 4, thread control: hang Stop and restore optimistic lock and pessimistic lock 1. Optimistic lock optimistic state, that is, assuming that my data will not be accidentally modified, if modified, give up to start all over again. 2. Pessimistic locking is in a pessimistic state, that is, assuming that my data must be modified, it is simply possible to lock it directly.

Introduction to Java Collection

Three subinterfaces of the collection interface:

1 、 set

2 、 list

3 、 Queue

Collections can be roughly divided into the following four systems:

1. Set: unordered, non-repeatable set

2. List: an ordered, repeatable set

The classes commonly used to implement the list interface are LinkedList ArrayList Vector and Stack.

3. Map: represents a set with a mapping relationship

4. A new addition to Queue:Java5, which represents a queue collection implementation

The difference between sets and arrays

1, array length initialization specified, can only save fixed-length data, the collection can save an uncertain amount of data, but also can save data with a mapping relationship.

2. Array elements can be values of basic types or objects, collections can only be objects, reference variables of objects are actually saved, and variables of basic types must be converted to wrapper classes for them before they can be put into the collection.

Map and collection are the root interfaces of the Java collection framework. Key in map is non-repeatable and is used to save data with mapping relationships.

Redis

What is cache traversal?

Under normal circumstances, the queried data exists. If a non-existent data is requested, that is, the data cannot be found in the cache and database, it will be queried in the database every time, which will increase the pressure on the database.

Resolve:

1. Cache null value, that is, set the key that is not in the cache to only null.

2. BloomFilter, which is similar to a Hbase set used to determine whether an element (key) exists in the collection. We put the key of the data in the Bloom filter, and each query will be judged. If not, it will directly return null. It has no delete operation and can be combined with cache null values.

What is a cache avalanche

When a large-scale cache invalidation is sent at some point, such as when the cache server goes down.

Resolve:

1. Reduce the probability of service downtime by using clusters.

2. Ehcache local cache + Hystrix current limit and downgrade.

The second-tier cache can be supported for a while when considering that redis Cluster is not available at all.

Use Hystrix to limit or downgrade the current, such as 5000 requests in 1 second, set to 2000 requests, and the rest follow logical flow.

What is cache breakdown?

In the case of high concurrency, when a large number of requests query the same key at the same time, the key just fails, which will cause these requests to query the database at the same time, resulting in excessive database requests at a certain time.

Solution:

1. Adopt distributed lock

Only the first request (thread) that gets the lock requests the database, and then inserts the cache. Of course, you have to check the cache every time you get the lock.

To solve the problem of failure in hot data sets for hot data, when the cache fails, there will be a large number of requests, and then call the database, resulting in the collapse of the database. Solution: 1, set failure time 2, use cache breakdown method, lock 3, set cache never to expire, that is, use scheduled tasks to update cache and expiration time of cache that is about to expire. The above is the content of this article on "what are the concepts of springMVC and spring". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 211

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report