java notes frame portion

What is the framework?

The frame is a frame of mind, refers to the binding, it is also a rack ------- refers to supporting.

MVC pattern

MVC refers to a model (model) - view (view) - the controller (Controller) abbreviations.

Jsp+servlet+javaBean

What is the MVC framework?

In order to solve the traditional MVC pattern (J SP + + javaBean the servlet) frame number of problems arise.

Traditional MVC model problem

1, all of the Servlet and Servlet mapping must be configured in web.xml , if the project is too large, web.xml would be too large and can not be modular management.

2, Servlet main function is to accept parameters, calling logic, jump pages, like other character encoding, uploading files and other functions have to write in Servlet , you can not let Servlet main function needs to do something about the exception.

3 , accepts a parameter troublesome (String name = request.getParameter ( "name"), the User User = new new user.setName the User (name)) , can not model receives, only a single receiver, after receiving the package to complete the conversion model.

4 , the jump page mode is single (forword, redirect), and when I need to change the page name is changed Servlet

 

Now more commonly used MVC framework are:

   struts

   Struts2

   Spring MVC

Simple talk about struts2 flow of execution?

Struts2 principle ?

A request Struts2 the process frame roughly divided into the following steps:

Interview:

1, the browser sends a request, through a series of filters, the filter reaches the core (StrutsPrepareAndExecuteFilter).

2, StrutsPrepareAndExecuteFilter by ActionMapper determine whether the current request an Action process , if not, then take the original process. If you need to put the request to the ActionProxy to deal

3, ActionProxy by Configuration Manager inquiry frame configuration file (Struts.xml) , find the need to call the Action class;

4, create a ActionInvocation instance, to call the Action corresponding method to get the result set name, before and after the call to implement the relevant interceptors.

5, by the result set Name know the result set corresponding to the response to the browser.

Interception, judgment, looking, execution, response

Struts2 interceptors in, you do with it?

    struts2 function (parameter processing, file upload, character encoding, etc.) are implemented using a system of interceptors.

If the business needs, of course, we can also customize the interceptor , be pluggable configuration, in the implementation of Action before and after the method of adding the relevant business logic to complete.

scenes to be used:

1, users log on to judge, in the implementation of Action to determine whether the previous login, if not logged jump to the login page.

2, user rights determination, performed in Action front of determining whether, and if not to give permission message.

3, the operation log ......

4、......

Simple talk about SpringMVC the implementation process?

Fast memory skills:

Core controller captures the request, look Handler, perform Handler, select ViewResolver, by rendering view and return ViewResolver

Talk about struts2 and springMVC What is the difference?

1. The core controller (front controller, the controller pretreatment): Spring MVC core controller is the Servlet , and Struts2 is the Filter .

2. The controller instance: the Spring Mvc than Struts faster.

3. management: So spring for a spring mvc more simple controller management.

4. The transmission parameters: the Struts2 in itself provides a variety of parameters accepted by the fact ( the ValueStack passed and assignment), and SpringMvc is received parameter method.

5. learning curve: SpringMVC than strats simple.

6.intercepter implementation mechanism: Struts has its own interceptor mechanism, the Spring MVC with independent AOP way.

7.spring mvc processing ajax request , and direct the data returned by struts2 is processed by way of plug

Talk about spring in two core?

AOP and IOC

Spring What is?

AOP and IOC container frame, it is a lightweight container.

AOP What is? What do you take it?

AOP: Aspect Oriented Programming

      We primarily use AOP to do:

      1 , transaction processing

      2 , the authority to determine

      3 , Log

Talk about Spring propagation characteristics of the transaction

 

1. PROPAGATION_REQUIRED: If there is a transaction, the current transaction support. If no transaction is open
2. PROPAGATION_SUPPORTS: If there is a transaction, support the current transaction. Without a transaction, the non-execution of transactions
3. PROPAGATION_MANDATORY: If there is already a transaction, support the current transaction. If there is no active transaction, an exception is thrown.
4. PROPAGATION_REQUIRES_NEW: Always start a new business. If a transaction already exists, the existing transaction pending.
5. PROPAGATION_NOT_SUPPORTED: Always perform non-transactional, and suspend any transaction exists.
6. PROPAGATION_NEVER: Always perform non-transactional, if there is an active transaction, an exception is thrown
7. PROPAGATION_NESTED:. If there is an active transaction, run in a nested transaction if there is no active transaction, press TransactionDefinition. PROPAGATION_REQUIRED properties to perform

 

 

Propagation

Required it needed if there is a transaction, the current transaction support. If no transaction is open

Supports support if there is a transaction, support the current transaction. Without a transaction, the non-execution of the transaction

Mandatory necessary  if there is already a transaction, support the current transaction. If there is no active transaction, an exception is thrown.

required_new always open a new business. If a transaction already exists, the existing transaction pending.

Not_support always perform non-transactional, and suspend any transaction exists.

Never never always non-transactional executed, if there is an active transaction, an exception is thrown

Nested Nested  if it is nested, not on open matters

Spring transaction isolation level
1. ISOLATION_DEFAULT: This is a PlatfromTransactionManager default isolation level, use the default database transaction isolation level.

In addition to the four JDBC isolation level corresponding to
2. ISOLATION_READ_UNCOMMITTED: This is the lowest transaction isolation level, it makes outside the allowable charge a transaction can see the data that uncommitted transactions.
      This isolation level will have dirty reads, non-repeatable reads and phantom reads.
3. ISOLATION_READ_COMMITTED: to ensure that after a transaction modifies the data submitted in order to be read by another transaction. Another transaction can not read data of the transaction uncommitted
4. ISOLATION_REPEATABLE_READ: This transaction isolation levels prevent dirty reads, non-repeatable reads. But the phantom read may occur.
      In addition to ensuring that a transaction can not read data from another uncommitted transaction, but also to avoid the following situation to ensure the production (non-repeatable read).
5. ISOLATION_SERIALIZABLE This is the most expensive, but the cost of the most reliable transaction isolation level. The transaction is processed as a sequential execution.

In addition to prevent dirty reads, non-repeatable read, but also avoids the phantom read.

What is ORM?

 Object-Relational Mapping ( Object Relational the Mapping , referred to as the ORM ) is a mode oriented in order to solve the object of the relationship between the phenomenon and do not match the existing database technology.

iBatis (mybatis) with Hibernate What is the difference ?

Same point:

   All java in orm framework, shielded jdbc api -level access details, we do not use the jdbc api to deal with, you can complete persistence operations on the database.

   ibatis benefits: providing a set of functions called the package will automatically result set objects and entity objects .

   Hibername benefits: Hibernate is a fully automatic orm mapping tool, it can automatically generate sql statement, and to execute and return java result.

difference:

1, hibernate than ibatis many powerful features. Because hibernate automatically generated sql statement.

2, ibatis can come out complex statements, and hibernate can not.

3, ibatis than hibernate simpler. ibatis oriented sql , and between different objects considering some complex mappings.

Hibernate mapping object status:

Temporary state, persistent state, free state, deletion status

Tell us about Hibernate cache ?

A, Why (why use Hibernate cache?)

In order to provide access speed, the disk or database access becomes a memory access.

Two, the What ( Hibernate cache principle is what?)

  Hibernate the buffer cache and secondary cache partition.

   Level cache is Session -level cache, the effective range within a transaction , the built-in can not be uninstalled. Secondary cache is SesionFactory level cache, from application to application launch end effective. Is optional, no default secondary cache, you need to manually open.

    After saving the database, save a copy in memory, if necessary to update the database updated simultaneously.

 What kind of data suitable for storage to the second level cache?   

1)  rarely modified data  post last reply time 

2)  frequently requested data   places the electricity supplier

2) is not very important data that allows concurrent data appears occasionally   

3) data will not be concurrent access   

4) constant data

Extended: Hibernate secondary cache by default does not support distributed cache. Use memcahe, redis other central cache to cache instead of two.  

Simple talk about the webservice scene used?

webservice is a SOA (service-oriented programming) architecture, it is language-independent, platform-independent, we can achieve mutual calls between different languages through the Internet -based Http interaction between the network application protocol.

1, real Liezi:

       Weather Forecast: can achieve webservice client calls a remote weather service implementation.

       Single sign-on: a service is to log all systems

Guess you like

Origin www.cnblogs.com/bianshiguang/p/10990018.html