Sinochem Technology Department 2018.4.16
1. Difference between callable and thread
Threads that implement the Callable interface can return execution results, while Runable cannot. The call method of Callable allows throwing exceptions.
Since Callable can return the execution result, if one thing can be divided into more than one, and then merge the results, Callable can be used
public interface Callable<V> { V call() throws Exception; }
public interface Runnable { public abstract void run(); }
2. swithc case supports byte short char int String (after java 7) and enumeration.
3. select 1 from where con limit 0,1; copy create table new table like old table. .
create table new table select * from old table (table structure and data will be copied)
4. Several ways of reflection
What is reflection: The java reflection mechanism is that in the running state, for any class, all the attributes and Methods, for any object, can call its properties and methods. This function of dynamically obtaining class information and calling methods
of objects is called reflection. .
There are several ways
Object.getClass(); The object has all, and what is reflected Class.class
; There is no third flexible
Class.forName (full path name)
5. Spring mvc and spring context relationship
Parent -child relationship. The context corresponding to spring mvc is a subcontext of spring, which can access properties in the spring context.
Reference: https://www.cnblogs.com/huntdream/p/6012390.html
The so-called traditional type is the three-tier architecture of action, service, and dao, which is based on the development model of large companies based on complex business.
For this mode, the general spring context is controlled at the service and dao layers, and the integrity of things is also controlled at the service layer; while springmvc-servlet controls the action layer.
Such a result leads to the following calling relationship:
- Action can call service and dao;
- service and dao cannot call action;
- The aop of the spring context container cannot be applied to the action layer, but similar things can be done by defining it in springmvc-servlet.xml.
//spring的上下文
WebApplicationContext ac1 = WebApplicationContextUtils.getWebApplicationContext(request.getSession().getServletContext());
//springMVC的上下文
WebApplicationContext ac2 = RequestContextUtils.getWebApplicationContext(request);