Framework face questions

First, in your own words briefly describes the execution flow of struts2.


Struts 2 frame itself can be divided into three parts: the core controller FilterDispatcher, enterprise business components of the business logic and user-implemented controller Action.
The core is the basis for the controller FilterDispatcher Struts 2 frame contains control flow and processing mechanism within the frame.
Business Action controller and business logic components that require the user to own implementation. User Action in the development and business logic components, also need to write the relevant configuration file for the core controller FilterDispatcher to use.
Struts workflow 2 relative to the Struts 1 should be simple, and WebWork framework is basically the same, so that Struts 2 is an upgraded version of WebWork. The basic process is as follows briefly:
1, the client browser makes an HTTP request.
2. web.xml configuration, the request is received FilterDispatcher.
3, according to the configuration struts.xml find Action classes and methods need to call through IoC manner, to the value of the injected Aciton.
4, Action to call the business logic processing business logic components, which comprises a step form validation.
5, Action finished, return the results to find the corresponding result according struts.xml configuration, and jump to the corresponding page

Second, the principle of struts2 turn:

a request processing in Struts2 frame roughly divided into the following steps
1 to initialize a pointer to the client Servlet container (such as Tomcat) request
2 request through a series of filters (the Filter) (these filters have called optional filter ActionContextCleanUp. this filter is useful for integrated Struts2 and other frameworks, such as: SiteMesh Plugin)
3 FilterDispatcher then be called, asking FilterDispatcher ActionMapper to decide whether to call this please an Action
4 ActionMapper decide if you need to call an Action, FilterDispatcher the processing of the request to the ActionProxy
5 the ActionProxy profile by asking the framework of configuration Manager, find the need to call the Action class
6 ActionProxy create an instance of a ActionInvocation.
7 ActionInvocation instance naming scheme that call, before or after the Action procedure call, calls involving related interceptor (interceptors are) a.
8 Action Once finished, ActionInvocation responsible for finding the corresponding return results based struts.xml configuration.
Return result is usually (but not always, it may be an additional Action chain) or a JSP template is represented FreeMarker needs. You can use Struts2 framework inherited labels in the course of representation.
In this process, the need to involve ActionMapper

In the course of all objects (Action, Results, Interceptors, etc.) are by ObjectFactory to create.



Five, Hibernate works:

Read and parse the configuration file
read and parse mapping information, create SessionFactory
open Sesssion
create a transaction Transation
persistence operations
commit the transaction
close the Session
closed SesstionFactory


Six, Hibernate What are the benefits:


JDBC database access code to make a package, simplifies the data access layer tedious repetitive code.
Hibernate is a JDBC-based persistence framework mainstream, is an excellent ORM implementation. His coding great extent simplified DAO layer
hibernate using Java reflection mechanism, instead of bytecode program to implement transparency.
hibernate performance is very good, because it is a lightweight frame. Flexibility mapped very well. It supports a variety of relational databases, complex relationships from one-to-many.

 

Seven, Hibernate is how lazy loading:

 

1. Hibernate2 lazy loading achieved: a) the entity object b) collection (Collection)
2. Providing the Hibernate3 lazy loading function attributes
Hibernate query data, the data is not present in the memory, when the program operation on the data when the real when the object exists only in memory, on the realization of a deferred load, he saves the cost of the server's memory, thus improving the performance of the server.
3. Hibernate how to achieve in relations between classes (eg: many, many relationships)?
Relationship between class and class is mainly reflected in the relationship between the table and the operating table, they operate on the object city, we program all the tables and classes are mapped together, they pass many-to-one configuration file, one-to-many, many -to-many,

 

Eight, Hibernate's query:
Sql, Criteria, Object comptosition
Hql:

Attribute query
parameter query, the query named parameters
associated with the query
paging query
statistics function

 

Nine, Hibernate said cache mechanism of the
presence of internal cache Hibernate 1. In a known cache, things belonging to the application-level cache
2. secondary cache:
A) application and buffer
b) distributed caching
condition: data will not be a third party modify the acceptable range of the data size, data update frequency is low, the same data is frequently used system, non-critical data
implemented c) a third party caching

 

Ten, how to optimize the Hibernate:

A) application and buffer
b) distributed caching
condition: the data is not modified by a third party, the acceptable range of the data size, data update frequency is low, the same data is frequently used system, non-critical data
c) third-party cache implementations


Twelve, spring works:

1.spring mvc please all requests submitted to DispatcherServlet, it will be entrusted to other modules of the application system is responsible is responsible for processing requests for real work.
2.DispatcherServlet query one or more HandlerMapping, find Controller to process the request.
3.DispatcherServlet please submit a request to the target Controller
after 4.Controller business logic processing, returns a ModelAndView
5.Dispathcher query one or more ViewResolver view resolver find ModelAndView specified object view object
6. the view object responsible for rendering back to the client.


Thirteen, why should spring:

AOP allows developers to create non-behavioral concerns, called crosscutting concerns, and insert them into the application code. After using AOP, public services
(such as logging, persistence, transactions, etc.) can be broken down into aspects and applied to the domain objects without increasing the complexity of the object model domain objects.

IOC allows you to create application environments that can construct the object, and then pass their collaborators to these objects. As indicated by the word upside down, IOC Anti like
over JNDI. Do not use a bunch of abstract factory, the service locator, single element (Singleton) and configured to direct (straight construction), with which each object is constructed collaborators. So it is managed by the container collaborators (collaborator).

Even if a frame Spring AOP, IOC is also a container. Spring is the best place it can help you replace the object. With Spring, as long as the properties and the profile JavaBean added dependencies (collaborators).
Then it can be easily replaced with a similar interface collaborators when required.

 


Fourth, you talk about the integration of SSH:

The SSH:
the Struts (Presentation Layer) + Spring (business layer) + Hibernate (persistence)
the Struts:
the Struts framework is a presentation layer, the main role is to show the interface, receiving a request, distribution request.
In the MVC framework, Struts belongs to the VC level, responsible for the performance of the interface, responsible for the distribution MVC relations. (View: follow JSP)
Hibernate:
Hibernate is a persistence framework, it is responsible for the operation and the relational database.
The Spring:
the Spring framework is a business layer, is an integrated framework can be a good bonding presentation layer and persistence layer.

 

Fifth, tell us about Spring's transaction management:

The transaction is a series of database operations (such as insert multiple data) unified commit or rollback, if you insert success, then together, if there is a middle of an exception, so all operations before the rollback.
This will prevent dirty data, database data to prevent problems.
To avoid this development generally transaction management. Spring also has its own transaction management mechanism, generally using TransactionMananger management, this function can be done by Spring injection.

 


Transaction Manager provides spring can be divided into two categories: programmatic and declarative. Programmatic, more flexible, but the large amount of code, code more duplicate; formula declarative programming than more flexible.

Programmatic mainly used transactionTemplate. Omitted part of the submission, rollback, a series of transaction object definition, to be injected into the transaction management objects.


Sixteen, Spring inside how to configure a database-driven?

使用”org.springframework.jdbc.datasource.DriverManagerDataSource”数据源来配置数据库驱动。示例如下:
<bean id=”dataSource”>
<property name=”driverClassName”>
<value>org.hsqldb.jdbcDriver</value>
</property>
<property name=”url”>
<value>jdbc:hsqldb:db/appfuse</value>
</property>
<property name=”username”><value>sa</value></property>
<property name=”password”><value></value></property>
</bean>


Seventeen, Spring inside applicationContext.xml file can not be changed to a different file name?

ContextLoaderListener is a ServletContextListener, it is initialized when you start the web application.
By default, it will find the Spring configuration in the WEB-INF / applicationContext.xml file. You can a <context-param> element named "contextConfigLocation" to change the location of Spring configuration file by definition. Examples are as follows:

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/xyz.xml</param-value>
</context-param>
</listener-class>
</listener>


Eight, how to configure the spring inside a web application?

Was added with the following content in web.xml /WEB-INF/applicationContext.xml loading content in the web server at startup.
<the servlet>
<the servlet-name> context </ the servlet-name>
<the servlet-class>
org.springframework.web.context.ContextLoaderServlet
</ the servlet-class>
<Load-ON-Startup>. 1 </ Load-ON-Startup >
</ the servlet>
obtained by ApplicationContext instance of class
WebApplicationContextUtils.getWebApplicationContext


Ninth, which defines how Spring hibernate mapping?

Add hibernate mapping file to applicationContext.xml file in the web / WEB-INF directory. Examples are as follows:
<Property name = "mappingResources">
<List>
<value> ORG / AppFuse / Model / User.hbm.xml </ value>
</ List>
</ Property>

XX, explain Dependency injection (DI, dependency injection) and IOC (Inversion of control, inversion of control)?

DI Dependency injection is a pattern programming model and architecture, also known as inversion of control for some time, although technically speaking, the IOC Dependency injection is a particular implementation,
dependency injection means is applied to an object to another object to provide a special capabilities such as: the parameters of a database connection has been passed in the form of a structure of the object itself instead of creating a method which is connected to the interior of a subject.
Inversion of Control and the Dependency Injection basic idea is that the conversion from the class dependent classes inside to the outside to reduce dependence
application control reversal, when the object was created by an entity external objects within a regulation system, on which it depends referenced object passed to it. It can be said, it is injected into the subject dependency.
So, Inversion of Control is a reference on how to obtain a target object on which he relies, reverse this responsibility.

 

XXI role in the spring of BeanFactory with ApplicationContext What?

1. BeanFactory bean responsible for reading configuration files, manage the bean is loaded, instantiated, maintain dependencies between bean, responsible for the lifecycle of the bean.
2. ApplicationContext BeanFactory addition to providing the above can be provided, but also provides a more complete framework functions:

. a support internationalization
b resource access:. Resource rs = ctx getResource ( "the CLASSPATH: config.properties"), "File: c: /config.properties"
c event delivery: ApplicationContextAware by implementing the interface
3. Common Gets ApplicationContext method:
a FileSystemXmlApplicationContext: Create a file system or the url specified xml configuration file, the configuration parameters for the file name or file name array
ClassPathXmlApplicationContext: Create from the classpath xml configuration file, the configuration file can be read from the jar package
WebApplicationContextUtils: the web the root of the application reads the configuration file, you need to configure in web.xml, you can configure the listener or servlet to achieve

 

Twenty-two, spring in those core classes, have any effect?

BeanFactory: generating a new instance, embodiments may implement a single mode
BeanWrapper: the get and set to provide a unified method
ApplicationContext: framework providing implemented, including all the features of BeanFactory

 

Xxiii, aop what is, what is the role aop?

Aspect Oriented Programming (AOP) provide another of thinking about program structure in this way to make up for the shortage of object-oriented programming (OOP) in
addition to class (classes), AOP section is provided. Cut the face of concerns modular, across multiple types and objects such as transaction management
a key component of Spring is the AOP framework, free to choose whether to use AOP
to provide declarative enterprise services, especially as a replacement for EJB declarative services . The most important such service is declarative transaction management, which builds on Spring's abstract things management
allows users to implement custom aspects, complementing their use of OOP with AOP's
possible Spring AOP as an enhancement of Spring

 

XXIV use Spring What are the benefits?

◆ Spring can effectively organize your middle tier objects, whether or not you choose to use EJB. If you only use Struts or other J2EE-specific APIs included in the framework, you will find Spring concern the problem of legacy.

◆ Spring can eliminate the excessive use of Singleton on many projects. In my experience, this is a major problem, it reduces testability and object-oriented system features.
◆ Spring can eliminate the need to use custom file properties of various formats in the whole application and engineering, can be configured through a consistent approach. Once confused, you are looking for a particular type of psychedelic properties keywords or system attributes, this had read the Javadoc or even source coding it? With Spring, you can very easily see JavaBean property class. Using an inverted control (discussed below) to help complete this simplification.
◆ Spring via interfaces rather than classes promote good programming practice, reduce programming costs to almost zero.
◆ Spring is designed to allow applications to use it to create as little as possible dependent on his APIs. Most business objects in Spring applications are not dependent on Spring.
◆ applications that use Spring to create easy unit testing.
◆ Spring can make the use of EJB has become an inevitable choice to realize a choice, rather than the application architecture. You can choose to use POJOs or local EJBs to implement the business interface, but does not affect the calling code.
◆ Spring helps you solve many problems without using EJB. Spring can provide replacement for an EJB, which are suitable for many web applications. For example, Spring can use AOP to provide declarative transaction rather than through the use of the EJB container, if you only need to deal with a single database, even without JTA implementation.
■ Spring provides a consistent framework for data access, whether using JDBC or O / R mapping products (such as Hibernate).
Spring you can really make the simplest possible solution to solve your problem. These properties are of great value.
To sum up, Spring has the following advantages:
Very low Low ◆ intrusive design, code pollution
◆ independent of the various application servers, can truly Write Once, Run Anywhere commitment of
DI ◆ Spring mechanism reduces the complexity of the business objects replace
◆ Spring is not entirely dependent on Spring, developers are free to choose or part of the Spring Framework complete

 

 

Xxvii, your understanding of the MVC, MVC What are the advantages and disadvantages? Combined with Struts, explain how to use a Web application?
A:
the MVC design pattern (observer pattern application frame mode)
M: the Model (the Business Process Layer), business process layer model, the operation data, and the presentation layer independent
(Independent of presentation).
V: View (Presentation layer), the view, the display data by client-side data type, and the back layer perform significantly model
line results.
C: Controller (Control layer), the controller, i.e. the view layer and a bridge layer model, the flow of control data,
receive events emitted view layer, and redraws view of
one kind of framework MVC implementation model
Model 2 (Servlet-centric):
JSP + Servlet + JavaBean, to control the core, JSP is only responsible for data collection and display, Sevlet, connecting the view
and model, the view layer data sent to the model layer, the JavaBean, and data entities into traffic class, the traffic class
manager traffic data, entity data, carrier data, substantially most of such items are used to achieve the MVC pattern.
StrutsMVC framework (the Application Web frameworks)
Struts MVC implementation model is the use of two to achieve, it is the controller core.
Struts provides components to develop applications using the MVC:
Model: Struts model does not provide category. This must be made by the business logic of Web applications developers to
provide in the form of JavaBean or EJB

 

Twenty-eight, ajax is what and how it works?
AJAX

Ajax by the HTML, JavaScript? Technology, DHTML and DOM composition, this method can be distinguished clumsy Web interface will be transformed into interactive Ajax applications.
AJAX core of an object is XMLHttpRequest, all Ajax operations are inseparable from the operation of this object
XMLHttpRequest object associated methods:
open request
XMLHttpRequest.open (transfer mode, address, whether asynchronous requests)
are ready to perform
XMLHttpRequest.onreadystatechange
get executed The results
XMLHttpRequest.responseText

 

Guess you like

Origin www.cnblogs.com/wzn520/p/11056762.html