"Java seconds technology seconds kill interviewer" common face Test (vi)

Source: Internet
Author: User

62. Talk about your understanding of MyBatis?

MyBatis is an open source project for Apache Ibatis, which was migrated to Google code by the Apache Software Foundation in 2010 and renamed MyBatis. Migrated to GitHub in November 2013.

MyBatis is an excellent persistence layer framework that encapsulates the process of using JDBC to manipulate databases, allowing developers to focus on the SQL itself without having to expend effort to process such as registering drivers, creating connection, creating statement, setting parameters manually, Result set retrieval and other JDBC complex process code.

MyBatis the various statement (statement, PREPAREDSTATEMNT, CallableStatement) that will be executed by XML or annotations, The resulting SQL statements are generated by mapping Java objects and SQL in statement, and finally the SQL is executed by the MyBatis framework and the results are mapped to Java objects and returned.

程序员只需要关注sqlsession,即可完成mybatis的编程。

1. MyBatis configuration file

A) Sqlmapconfig.xml, this file as the global profile of the MyBatis, configured the MyBatis operating environment and other information.

b) Mapper.xml, this file acts as the SQL mapping file for MyBatis, and the SQL statement that operates the database is configured in the file. This file needs to be loaded in Sqlmapconfig.xml.

2, through the MyBatis environment and other configuration information constructs the Sqlsessionfactory, namely the session factory.

3, through the session factory to create sqlsession that is the session, the programmer through the Sqlsession session interface to the database to increase the deletion and check operation.

4, MyBatis the bottom of the custom Executor actuator interface to operate the database, executor interface has two implementations, one is the basic actuator (default), a cache executor, sqlsession the bottom is the operation of the database through the executor interface.

5, Mapped statement is also mybatis an underlying package object, it wraps the MyBatis configuration information and SQL mapping information and so on. A select\insert\update\delete tag in the Mapper.xml file corresponds to a mapped statement object, and the select\insert\update\delete tag's ID is mapped The ID of the statement.

A) Mapped statement defines SQL execution input parameters, including HashMap, base type, pojo,executor through Mapped statement to map the input Java objects into SQL before executing SQL. The input parameter mapping is the parameter set for PreparedStatement in JDBC programming.

Mapped statement defines SQL execution output, including HashMap, base type, pojo,executor through Mapped statement to map output results to Java objects after executing SQL. The output mapping process is equivalent to the parsing process of the results in JDBC programming.

62.SpringMVC of the implementation process?

1, the user sends the request to the front controller Dispatcherservlet

2. Dispatcherservlet received a request to call the Handlermapping processor mapper.

3. The processor mapper locates the specific processor according to the request URL, and returns the Processor object and the processor interceptor (if any) to Dispatcherservlet.

4. Dispatcherservlet calls the processor via the Handleradapter processor adapter

5, Handleradapter execution processor (handler, also known as the back-end controller).

6, controller execution completed return Modelandview

7, Handleradapter will handler execution results Modelandview return to Dispatcherservlet

8. Dispatcherservlet Pass Modelandview to Viewreslover view parser

9. Viewreslover to return to the specific view object after parsing

10. Dispatcherservlet view is rendered (the model data is populated into the view).

11. Dispatcherservlet Response User

The difference between 63.SpringMVC and STRUS2

1, Struts2 is class-level interception, a class corresponding to a request context, SPRINGMVC is a method-level interception, a method corresponding to a request context, and the method at the same time with a URL corresponding to the So it's easy to implement restful style from the springmvc of the architecture itself.

2, from the above reasons, Springmvc method is basically independent of the request response data, requests for data through parameters, processing results passed modelmap to the framework, the method does not share variables, and Struts2 all of its action variables are shared, each request creates a new action, and an Action object corresponds to a request context.

3. Because Struts2 needs to be encapsulated for each request, the variables of the servlet life cycle such as request,session are encapsulated into a single map, supplied to each action, and thread-safe, so in principle, it is more memory-intensive.

4, the Interceptor implementation mechanism, STRUTS2 has its own interceptor mechanism, SPRINGMVC with the independent AOP way, so that Struts2 configuration file volume is still larger than SPRINGMVC.

5. SPRINGMVC's entrance is the servlet, and Struts2 is the filter.

6, SPRINGMVC integration of Ajax, the use of very convenient, just a note @responsebody can be implemented, and then directly return the response text, and STRUTS2 interceptor integrated Ajax, In action, it is generally necessary to install plug-ins or write code to integrate them, it is relatively inconvenient to use.

"Java seconds technology seconds kill interviewer" common face Test (vi)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.