Short answer collection Mybatis, Spring, SpringMVC, SSM framework

The first question: Mybatis in the # {...} and $ {...} difference
Answer:
# {...}: "?" "?" Parameter location will make use of placeholders when executing SQL value will be replaced
$ {...}: directly to the value of the parameter as part of the implementation of SQL to SQL injection may be →
how to choose:
. . . when Insert Enter of Ginseng number Yes Make for S Q L Hold Row of One unit Minute of Time 使 {...}: When time parameters inserted as part of the SQL execution must use {...}
# {...}: is the time when the parameter passed to interact with the database, {...} # use
easily determined: the parameter passed in SQL whether single quotes. Single quotation marks may be used {...} #, not single quotation marks, using $ {...}

The second question: Mybatis use mapper interface development, you need to follow some of the constraints
answer:
the value of the namespace 1.mapper mapping file, must be equal to the fully qualified name mapper interface
id Sql of 2.mapper mapping file, must be equal method name mapper interface
3.mapper Sql mapping file with the same type must paramterType corresponding method.
the return value and the value 4. the method must be consistent resultType or resultMap

Third question: Maven common commands, and their meanings
answer:
root directory shift + right to open a command window
mvn compile compiler
mvn clean clear bytecode
mvn clean compile to clear the byte code, and then compile
mvn test execution test
mvn package in the current project package the .war .jar
mvn Clean Site help build the project documentation
mvn install the item labeled package installed maven repository

Fourth Question: The value of scope when managing dependencies Maven What? And what is the meaning of each value?
Answer:
1, the compile (compile range)
the compile is the default range; if not provided a range, that range is dependent on the scope of the compilation. Compiling range depends on all available in the classpath, while they will be packaged.
2, provided (provided range)
Provided dependence when used only in a container provided JDK or the dependency. For example, if you develop a web application, you may need to compile available in the classpath Servlet API to compile a servlet, but you do not want to include the Servlet API in the packaged WAR; the Servlet API JAR of your application server or servlet container available. It has provided a range of dependence can be used in compiling classpath (not runtime). They are not transitive, it will not be packaged.
3, runtime (running range)
Runtime At runtime dependency and test systems need, but need not at compile time. For example, you may only need JDBC API JAR at compile time, but only when it needs to run the JDBC
driver implementation.
4, test (test range)
the Test range depends in general do not need to compile and run time, they are only available in test compilation and test operation phase.
5, system (system-wide)
range depends similar system provided, but you must explicitly provide a path for the local system JAR file. This is done to allow the compiler based on local objects, and these objects are part of the system library. This component should be always available, Maven will not go looking for it in the warehouse. If you depend on a range set to system-wide, you must provide a systemPath element. Note that this range is not recommended (you should always try to rely on references from public or custom Maven repository).

The fifth question: Introduction Mybatis caching mechanism of
answer:
in memory to open up an area used to store data, the data is stored in memory called cache
Objective: To improve the efficiency of queries
principle: as memory cpu speed higher than the same interactions with the disk interactive the speed of the
essence: the Map
the mybatis cache into cache and secondary cache
cache:
every time you open a sqlsession objects when, in sqlsession will open in a space as a cache to store data
has some limitations: just a sqlsession internal scope, but sqlsession relatively short life cycle. Level cache for improved performance is very limited
really to be used to enhance the performance of secondary cache
secondary cache:
1, what kind of data to fit into the cache?
Frequently requested data, not frequently modified data, read write data much larger than
2, the cache hit rate is
the amount of data the amount of data retrieved from the cache / Total acquired data
3, the maximum survival time
data can be present in the memory the longest
cache and secondary cache can coexist
cache is sqlsession level
two cache is namespace level (the mapping file, added)

Question 6: Mybatis commonly used dynamic SQL label what
the answer:
if:
suitable for a part where the words contain dynamic
if the feature is
when it is determined if the condition is met, add tags if the words
when it is judged if the conditions are not satisfied when nothing was added
the Choose:
applies:
when the determination condition is true, a statement is executed
when the determination condition is false, execute another statement
where and set:
effect where a:
1, where when the label statement is not empty, will be before the statement stitching on "where" keyword
2, where the label if the statement is "and" or at the beginning of "or", then the "and" or "or" will be omitted
set of role:
1, if the set label statement is not empty, it will be at the beginning of stitching "set" keyword
2, if the statement is set tab "," at the end, then this "" will be removed
Trim:
prefix : prefix added before the string back to what the
suffix: suffix, what is added after the string returned
prefixoverrides: when the string contents of the beginning of the Content will be overwritten
suffixoverrides: when the string ends its contents, the contents are covered with
the Foreach:
Note: When the parameter interface array or collection method, MyBatis will automatically put the package into a parameter map
map the key parameter type, the first letter lowercase
Default: key array is "array", key set for "list", map the key to "map"
Collection: parameter key value in the package into the map of
open: represents What started string
close: the end of a string that represents what
item: each of the set to a nickname of the element
separator: elements in the set delimiter

Q7: Mybatis of Xml mapping file, different Xml mapping file, id if you can repeat?
Answer:
Different Xml mapping file, if a configuration namespace, then the id can be repeated; if there is no namespace configured, id can not be repeated.

Q8: When an entity class attributes and field names in the table is not the same, how to package objects
answer:
Method One: by defining field names in the sql statement query aliases, so that the alias field names and entities classes consistent attribute names.
Here Insert Picture Description
Method two: one to one relationship by mapping field names and the name of the entity class properties
Here Insert Picture Description
ninth questions: What is the role of association label? What common attributes and use the association tag is a role?
Answer:
Association or: processing a single associated object process association single attribute
property: injection to employees which attribute
select: Send which a sql statement
javaType: Object to which class the sql statement query the result set, the package to (may be omitted )
column: results of employees focused on the value of the column which is used as an object to conditions associated with the query

Question 10: mybatis achieve the associated object assignment in several ways, what are, please briefly briefly
answer:
Both are associated with the query and additional SQL query
associated with the query a SQL statement is sent to the main object and the Association encapsulated objects simultaneously check out.
additional SQL query is an SQL query to execute a primary object, according to the result set value of the main objects of the foreign key column, an SQL query executed further associated object, and assigned to the master object.

Eleventh question: creating Spring objects DESCRIPTION manner
answer:
1, the constructor
2, static factory
3, Example Chemical
4, the interface implemented FactoryBean

Twelfth title: Spring / SpringMVC common notes and its role (at least 8)
answer:
@ the Component, @ Repository, @ Service, @ the Controller: a Spring-managed object class is created
@ Autowired, @ Resource: from container Gets the class object and to field assignment
@RequestMapping: access path mapping method
@ResponseBody: convert method returns the object to JSON
the @Scope: set the object scope
@ PostConstruct, @ PreDestory: life cycle setting object
@Aspect: set to cut class
@Transactional: Add transaction control

Thirteenth question: Tell us about understanding of Spring's IoC / DI's
answer: Spring's IoC and DI are describing the same concept from different angles. IoC emphasize the rights object created is done by Spring. DI emphasized that properties of the object by automatic injection Spring value.

Fourteenth question: @Autowired annotation order to obtain the object when the field value is injected from the container
Answer: First, in accordance with the type field of acquisition, if no type will throw an exception if there is a matching type will be directly injected;. If there are multiple types of matches, and then look for the object named as the field name. If you can find the direct injection, if there is no matching name how to throw an exception

XV title: Spring IoC complete functionality of four notes, as well as the respective roles of
the answer:
four annotated with @ Component, @ Repository, @ Service , @ Controller
four annotation functions to complete the same.
Difference is: different notes marked components in different layers.
@Repository denoted Dao layer assembly
@Service business layer components are denoted
@Controller layer control layer assembly denoted
@Component label can not accurately distinguish which one component belongs

XVI question: static and dynamic agent Proxy difference
answer:
the static agent before the program is run has existed bytecode proxy object, the relationship between the target object and proxy object before the program is run has been determined.
Dynamic agent proxy object is not run before the program bytecode JVM byte code is generated dynamically during program execution. proxy objects and relationships in the proxy object is determined when the program is run.

Seventeenth title: similarities and differences between BeanFactory and ApplicationContext the
answer:
Both are container object can manage Spring Spring container.
The difference is, ApplicationContext is a BeanFactory sub-interfaces .ApplicationContext addition to achieving the addition BeanFactory interface also implements messaging, internationalization, and other interfaces. Therefore ApplicationContext is more powerful.
two containers at the time to create objects of different .BeanFactory that will create objects in acquiring the object from the container, while the ApplicationContext container object is instantiated when the managed object container will be instantiated.

Eighteenth problem: Check the permissions exist in the class com.text.oa.permissionPermissionCheck class check () method, is now in all methods com.text.oa.service.DepartmentService, at the beginning of the process to add permission checks function, write the xml configuration code aop
answer:

<bean id="pc" class=com.text.oa.permissionPermissionCheck""></bean>
<aop:config ref="pc">
	<aop:pointcut id="pointcut" expression="execution( *com.text.oa.service.DepartmentService.*(..))">
	<aop:before method="check" pointcut-ref="pointcut"/>
</aop:config>

Nineteenth question: Enhanced AOP Five different timing of the Spring are what is, and briefly explain
the answer:
the before: pre-enhancement operations performed in the beginning of the method
after-returning: Rear enhanced executed when the method returns the operation
after-throwing: abnormal enhancement, the method operations performed when an exception occurs
after: final enhancement operations performed after the end of the process, regardless of whether the method will be executed normally ends
around: surround reinforcement, reinforcing manner can customize

Article title: the advantages of both declarative transaction management Spring
answers:
xml way: the advantage, unified configuration in xml configuration file can be configured for all business transactions need to add some method by simultaneously adding affairs, unified management, easy maintenance drawback is: profiles tedious process, configuration files bloated.
Notes ways: the advantage of simple configuration, only need to mark notes in business class can add transaction drawback is the need for all you need to add transaction type annotation notes, Configuring dispersed, is not conducive to maintenance.

Twenty-first question: SpringMVC in, forward and redirect the role of string
Answer:
common features of the two strings is the view resolver prefixes and suffixes will not take effect .forward role is to forward the request to jump way view page, redirect redirection is a way to jump to the page view

A twenty-second problem: the execution flow SPRINGMVC
Answer:
Here Insert Picture Description
(1) the user sends a request to the front-end controller the DispatcherServlet;
(2) the DispatcherServlet after receiving the request, the call processor HandlerMapping mapper request to obtain the Handle;
(. 3) mapping processor url finds particular processor according to a request, the object generation processor and a processor blocker (if any is generated) collectively returned to the DispatcherServlet;
(. 4) to call the DispatcherServlet HandlerAdapter processor adapter;
(. 5) adapted to invoke particular through HandlerAdapter a processor (Handler, also called back-end);
(. 6) perform complete Handler returns ModelAndView;
(. 7) Handler HandlerAdapter is the execution result is returned to ModelAndView the DispatcherServlet;
(. 8) to the DispatcherServlet ModelAndView pass parser parses ViewResolver view;
(9) ViewResolver DETAILED view returns parsed;
(10) of the DispatcherServlet view render view (model data coming filled view)
(. 11) in response to the DispatcherServlet user.

Twenty third question: Configuration SpringMVC request encoding filter (org.springframework.web.filter.CharacterEncodingFilter)
answer:

<filter>

	<filter-name>CharacterEncodingFilter</filter-name>

	<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>

	<init-param>

		<param-name>encoding</param-name>

		<param-value>utf-8</param-value>

	</init-param>

</filter>

<filter-mapping>

	<filter-name>CharacterEncodingFilter</filter-name>

	<url-pattern>/*</url-pattern>

</filter-mapping>

The twenty-fourth problem: the user (user) analysis table paging, each page is displayed when ten data, check out what the SQL statement in five data is?
The answer:
the SELECT * from the User limit 40, 10

Twenty-fifth problem: using a response frame SpringMVC JSON object development steps (front controller, the controller has the Controller configuration)
Answer:
1. Import jackson dependent
2. Create method returns the object and annotation @RequestMapping, designated access path method of
labeling @ResponseBody notes 3. methods.

Twenty sixth question: HanderInterceptor interface defines what methods, the methods of the interface class in implementation were executed at what time to
answer:
preHandle: Handler executed before execution method
postHandle: After performing Handler method, executed before view rendering
afterCompletion: return ModelAndView, after view rendering performed.

Twenty seventh title: Method presence List queryAll () in UserMapper interface, how to use PageHelper plugin API to query paging (write pseudo code to)
answer:
PageHelper.startPage (the pages, each display quantity);
List List mapper.query = ();
PageInfo new new info = PageInfo (List);

Twenty-eighth or False: Spring and Mybatis integration, configuring SqlSessionFactoryBean, which attribute values need to inject value (or attribute meaning to write the name of the property may be)
Answer:
data sources (dataSource)
associated mybatis profile (configLocation)
associated mapper mapping file (mapperLocations)
configure an alias (typeAliasesPackage).

Twenty ninth question: When configuring SpringMVC front controller, "/" and "/ *" What is the difference, whether configured as "/ *"
The answer:
"/ *" matches .jsp file, "/" does not match .jsp file can not be configured as "/ *", because the configuration is "/ *", then all jsp files will be blocked front controller, but the front-end controller can not handle jsp files.

Thirty or False: SpringMVC Returns String and ModelAndView, jump pages and how to transfer data to a page, follow the instructions are
the answers:
the return character String, the string is returned directly to the corresponding name of the view, you can use the method addAttribute Model object parameter transfer method in the data
return ModelAndView object, an object method addObject communicating data, using a method provided setViewName object name of the view.

Thirty questions: ResultMap and ResultType difference
Answer:
Both are the result of the query indicate a relationship between the set and java object, process the query result set is mapped to java object.
ResultMap: represents the query result set columns to-one mapping individual attributes bean object.
ResultType: represents the object class bean, this time can be omitted resultMap label map, it must ensure that the query result set of attributes and object class attributes bean is one to one, then case-insensitive, but limited.

He published 189 original articles · won praise 13 · views 10000 +

Guess you like

Origin blog.csdn.net/NewBeeMu/article/details/101161920