"SSH"---"Struts2, Hibernate5, Spring4" "Scatter knowledge"

Source: Internet
Author: User
Tags in domain


First, Struts2
1.1, the concept of Struts2
STRUTS2 is a framework for developing MVC applications that provides solutions to some common problems in the development of Web applications:
Verify the legitimacy of input data from the user;
? --Unified layout;
? scalability;
? internationalization and localization;
? Support Ajax
? Repeating submission of forms
? File upload Download (file crosses file type is not the ordinary type, but the multimedia data type "*.txt, *.doc, *.xls, etc.", because the form is not stored in ordinary data, so the form type also with the concept, The value of the form's property enctype must be multipart/form-data when uploading)

1.2, the core of Struts2
Filter Strutsprepareandexecutefilter (concept, work business process)
1.3. STRUTS2 Access request path suffix
->*.action
->*.do
->*.input (Custom)
Specific practices: <constant name= "struts.action.extension" value= "Action,jsp,input"/>
1.4. How to access Web resources in Strus2
1.4.1, what is a Web resource?
HttpServletRequest, HttpSession, ServletContext, and other native servlet APIs.
1.4.2, why do you want to access Web resources?
b/S application controller must access the Web resources: such as read-write properties to the domain object, read and write cookies, and so on.
Read-write properties in domain objects (domain objects are four scopes): Request.setattribute ("xxx")
1.4.3, how to access Web resources:
1.4.3.1, accessed in a way that is decoupled from the servlet API (Application program Interface)
1.4.3.1.1, through Com.opensymphony.xwork.ActionContext
1.4.3.1.2, through action to implement the following interface
->org.apache.struts2.interceptor.applicationaware
->org.apache.struts2.interceptor.requestaware
->org.apache.struts2.interceptor.sessionaware
1.4.3.2, accessed through a way to be coupled to the servlet API (Application program Interface)
1.4.3.2.1, Org.apache.struts2.ServletActionContext
1.4.3.2.2, by implementing the corresponding Servletxxxaware interface (Servletrequestaware,servletcontextaware,servletresponseaware)
1.4.4, four scope scopes:
1.4.4.1, page (scope range is active on the current page)
1.4.4.2, request (scope scope is a request, what is a request?) When we use a browser to open a resource on the network and even one request, the scenario example: submitting data to the server, such as registering a Renren account.
1.4.4.3, session (Scope is a session, the concept of conversation is when we go through the browser to really access a resource on the network (jsp/servlet/... Until we close the browser this time, even if one request), the scenario example: Tracking user session state.
1.4.4.4, application (scope is server-wide (that is, the server from the start to the end of the server shutdown), the scenario example: detect the current Web site number of people online.
1.5, struts.xml configuration related
1.5.1, package-is used to divide the system module, the equivalent of our Java package
1.5.2, action-configuration request to access the behavior class (what the behavior is, Java has the concept of attributes and behavior/methods)
1.5.3, id-the request path of the foreground submission data to the background action
1.5.4, class-the request path of the foreground submission data to the background action (this refers to the full name of the class)
1.5.5, method-Front desk submission of data specific methods/behaviors to be executed
1.5.6, Extends-struts gives us some features such as redirects, internal jumps, etc.
1.5.7, type-the corresponding type (specifically, there are several: chain, dispatcher, redirect, Redirectaction)
? Chain: Indicates forwarding to an action
? Dispatcher: Indicates forwarding (default value)
? Redirect: Indicates redirection
? Redirectaction: Indicates redirection to an action (the corresponding type can also be redirected to action via the redirect result)

1.5.8, name-action Business execution completed the logical path to jump, generally with the type of use
1.5.9, namespace-namespace (can access request path across namespaces)
A sub-node/request path for 1.5.10, result-action
1.6. How to access specific action in action
1.6.1, through wildcard access
1.6.2, by dynamic method invocation (Struts2 's dynamic method call is disabled by default, if it is to be used, it must be turned on, as follows, configured in Struts.xml: Strict-method-invocation= "false")
1.7. Internationalization
The role of internationalization is to be able to display the same program in different languages, such as Chinese web pages written in China if you want to be able to display in the island, then you need to be able to display in the Japanese environment Native2ascii encoding.
It is also important to note that the English language is displayed, and it is recommended to use American English instead of British English.
1.8, Struts2 of the form label, we generally use JSTL instead
1.9, Struts2 work flow (remember to remember it must be)
Second, Hibernate5
2.1, Hibernate5 core idea?
2.1.1, object-relational-mapping (Object relational mapping)
2.2, how to do orm?
2.2.1, the following points are required:
The attributes of the 2.2.1.1 and entity classes must correspond to the field one by one of the database table;
2.2.1.2, the entity class must have a field to reflect the uniqueness of the database row, hibernate requirements are self-increasing;
2.2.1.3, the entity class that requires mapping with database table must have corresponding mapping file;
2.3, Hibernate core configuration file specifically to configure what content?
2.3.1, data source (including driver address, connection address, user name, password)
2.3.2, dialect work must pay attention to what you use the database platform and version (remember to remember)
We use update in 2.3.3 and HBM2DDL work.
2.3.4, loading the entity class with the table mapping file
2.3.4.1, way one, XML way (the method is: <mapping resource= "Class of the full path, the path must be used/represented"/>)
2.3.4.2, way two, annotation way (notation is: <mapping class= "Class of the full path, the path must be used." >)
2.3.5 can also be configured to let hibernate display and format SQL
2.3.5.1, display: Show_sql value is: true
2.3.5.2, formatted: The Format_sql value is: true
2.4, Hibernate5 's core API
2.4.1, configuration-function is used to load the core configuration file, the official recommendation of the core profile file name and path is Hibernate.cfg.xml, the path is SRC.
The 2.4.2, sessionfactory-function is used to create sessionfactory, whose objects are created by the configuration.
2.4.3, session-function is used to create a Session, his object is created by Sessionfactory, the equivalent of JDBC inside the connection
2.4.4, transaction-transactions, which indicate which methods are under the control of the transaction (if you have questions about the transaction to ask Niang, but you have to know that there are four properties acid-atomicity, isolation, persistence, consistency)
2.5. Hibernate's primary key generation strategy (this point only needs to be remembered)
2.5.1, native (self-increment based on database underlying mechanism)
2.5.2, uuid (generated by hibernate a 32-bit character string, which is generated when the current time, the current computer network card MAC address and timestamp to synthesize, so is unique)
2.6. Buffering
2.6.1, buffering concept (see for yourself)
2.6.2, primary buffering (Session level buffering)
2.6.3, two buffer (we use a third-party buffer mechanism, commonly used Shiro, Redis, Memcached)
2.6.4, buffering characteristics (in the acquisition of data is the first to find a buffer, if you can find the return data, if not found in the database to query, find out immediately after the buffer inside, the next time to find the same or directly to find the buffer)
2.7. Hibernate transaction
2.7.1, transactional concepts, features
2.7.2, how to use transactions
2.7.2.1, by configuring in spring's core configuration file
2.7.2.2, using the annotation way (remember that you have to configure a subset of the XML)
2.8. Hiberante Common API
2.8.1, Query
2.8.2, Criteria
2.8.3, SQLQuery (Know it, we never use it)
2.9. Hibernate relationship mapping (always remember that Hibernate is maintained in two-way relationships)
2.9.1, One-to-many
2.9.2, Many-to-many
2.9.3, Realization Way
2.9.3.1, XML configuration
2.9.3.2, Annotation
2.9.4, cascading operations (CASCADE)
2.9.5, maintenance permission waiver (inverse)
2.10. Hibernate Query Method
2.10.1, object navigation diagram
2.10.2, OID (object ID query)
2.10.3, HQL
2.10.4, QBC
2.10.5, Local SQL
2.11. Hibernate retrieval Strategy
2.11.1, get (as soon as an executing program will send SQL statements to the database to execute)
2.11.2, load (do not immediately send SQL statements to the database execution, but use the object inside the specific properties of the time will be sent, equivalent to lazy loading)
2.11.3, Batch Crawl
2.11.4, Lazy (use as little as possible)
2.11.4.1, True (delay)-to be used
2.11.4.2, False (no delay)-No
2.11.4.3, extra (quite drops delay)-No
2.12. Database connection pool (we don't need to, because our framework integration is to be given to spring management)
2.13. Hibernate Work Flow
Third, Spring4
3.1. Spring Workflow
3.2, Spring's two core
3.2.1, aop-programming for facets
3.2.2, ioc/di-(IOC control inversion/inversion control, which is designed to give the creation of objects to spring for management, DI dependency injection, attributes that can be injected including basic and object properties)
3.3. Bean label
Name of the object of the 3.3.1, id-class
Full name of the 3.3.2, class-class
3.3.3, name-function and ID are the same, but have been discarded, no. Just a legacy attribute, in order to be compatible with STRUTS1.
33.4, scope-single case and many examples (need to know because we use struts action, action is a number of cases, so at the time of development, the value of scope is prototype)
3.4, bean instantiation of three ways
3.4.1, through the non-parametric construction method (must be)
3.4.2, through static factory class (must be)
3.4.3, through the example chemical plant (understand)
Note: There are two ways to instantiate a bean: 1, xml;2, Annotation
3.5. Transaction Configuration
3.5.1, first have data source (prerequisites)
2.5.2, configure transaction sessionfactory, inject datasource, inject hibernatetemplate (if used)
3.6, configure the connection pool (we use C3P0)

2017-08-18 18:49:37

"SSH"---"Struts2, Hibernate5, Spring4" "Scatter knowledge"

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.