1, Say it java Class set
2, String Hassey equality ,equals Is it equal ? And vice versa ?
3,Spring How it works , How to realize the inversion of control , How to write filter code by yourself
4, Have you seen the source code of the framework
5, How to realize dynamic agent
6,action Single instance or multiple instances
1) Struts2 Every request , Generate a Action To handle .
2) Spring Of Ioc Container managed bean The default is single instance .
Struts2 And Spring After integration , from spring To manage Struts2 Of Action, bean By default, if there is a single instance , There will be the following questions :
1) Action It's a single case , Of which FieldError,actionerror Error messages in Will accumulate , Even if the correct information is entered again , It can't pass the test .
2) Struts2 Of Action It's stateful , He has his own membership , So under multithreading , There will be problems .
How to solve ?
Scheme I : I don't need a single example , spring in bean The scope of is set to prototype, Each request corresponds to an instance .
Scheme II : spring in bean The scope of is set to session , each session Corresponding to an instance , Solved multithreading problem .( How to set scope : 4
spring in bean Scope of )
Write another interceptor , empty FieldError And actionerror
7, How to configure bean
8, Modify single instance multi instance
9,java Design mode of
10, Control of transactions
11, Stolen reading
Dirty reading, also known as invalid data reading , In database access , affair T1 Modify a value , Then the transaction T2 Read the value , thereafter T1 Undo the modification of the value for some reason , This leads to T2 The data read is invalid .
Dirty reading is when a transaction is accessing data , And modified the data , This change has not yet been committed to the database , At this time , Another transaction also accesses this data , And then I used this data . Because this data is not submitted yet , Then the data read by another transaction is dirty data , Operations based on dirty data may not be correct .
12, Propagation properties of transactions
REQUIRED： Business methods need to run in a transaction . If the method is running , Already in a transaction , Then join the transaction , Otherwise, create a new transaction for yourself .( The default is this transaction behavior )
NOT_SUPPORTED： Declaring a method does not require a transaction . If the method is not associated with a transaction , Container will not open transactions for it . If the method is in a transaction （ the other one bean） Called , The transaction will be suspended , After method call , The original transaction will be resumed .
REQUIRESNEW： Property indicates whether a transaction exists or not , Business methods always initiate a new transaction for themselves . If the method is already running in a transaction , The original transaction will be suspended , New transactions will be created , Until the end of method execution , The new business is over , The original transaction will resume .
MANDATORY： This attribute specifies that business methods can only be executed in an existing transaction , Business method cannot initiate its own transaction . If a business method is called without a transaction , The container will throw an exception .
SUPPORTS： This transaction attribute indicates , If a business method is called within a transaction scope , Method becomes part of the transaction . If the business method is called outside the scope of the transaction , Method is executed in a transaction free environment .
Never： The specified business method must not be executed within the scope of a transaction . If a business method executes in a transaction , The container will throw an exception , Only business methods are not associated with any transactions , To execute normally .
NESTED： If an active transaction exists , Run in a nested transaction . If there are no active transactions , Then press REQUIRED Property execution . It uses a single transaction ,
This transaction has multiple savepoints that can be rolled back . Rollback of internal transaction will not affect external transaction . It's only for DataSourceTransactionManager Transaction manager works
The database system provides four transaction isolation levels
( Among two or more concurrent transactions )
Dirty reading ： One transaction reads the uncommitted update data of another transaction .
Non repeatable ： In the same transaction , Reading the same data multiple times results in different results . In other words , Subsequent reads can read the submitted update data of another transaction . contrary ,“ Repeatable reading ” When reading data multiple times in the same transaction , Can guarantee the same data read , that is , Subsequent reads cannot read the submitted update data of another transaction .
Illusory reading ： One transaction reads the committed insert data
13, How to realize shopping cart
15, Count orders in a day
16,IN HAVING exsit
17, Have you ever used a scheduled task
18,JVM Memory management for ,
19, Heap memory , Stack memory overflow
20, Let's talk about caching
21, Count all duplicate users
select name,count(*) from tab group by name having count(*)>1;
1. How to call the interface written by others ? Interface written by myself , How to make others call
3.List,set,Map The underlying implementation principle of
Interview questions of Jingdong
1. Simple lazy is not thread safe in a multithreaded environment . It was suggested that getInstance() Synchronization lock on method , But it's probably too big to lock the whole thing in , Not conducive to efficiency .
Starved Han style of single case model , Instantiate member variables of their own types when they are defined , Make the Singleton Singleton class quilt system （ as it were ） A singleton object has been instantiated when loading , Thus, thread safety is avoided once and for all .