0. Written in front
friendly tip: Download the address below Oh.
The project has been basically completed, plus this summary, and the project related to the blog also wrote 30, add up, the process of writing a blog is a process of curing thought, useful to themselves, but also to help others. Incidentally, in the process of learning will certainly encounter a lot of anomalies appear, we have to do is to locate this anomaly, the general exception will be followed by one or more caused by:xxx, these are the cause of the anomaly, generally we find the bottom of a caused by, There is often the root of the problem. If you can't solve, you can go to Google, Baidu search (search when not a large pile of anomalies to the previous post, pay attention to search the key parts!) In general, we encountered problems, 99.9% of predecessors have encountered, the basic can be resolved, I met the problem can not be solved basically is so dry, their own resolution of more, there is a feeling ~ finally hope that everyone in reading my blog will be harvested!
Nonsense will not say, the following summary of this online mall project, I will not be exhaustive, mainly divided into several modules to summarize, including the use of what technology and so on, specific details I will attach a quick link in the article, you can view a specific article.
Recall this project, which can be divided into these major modules:
Construction of---project environment
---Set up the backstage management system
---Set up the foreground display page
---shopping cart related features
---online payment function
---the sending function of mail and SMS
Applications for---Domain names and deployment of projects
---form validation and report display
below for each module, do a specific analysis.
1. The project Environment constructs
This is a part of every project, and there will be a lot of messy problems, just beginning to learn ssh, always suffer from building the environment, because not too skilled, but skilled on the good, the main is to "rhythmic" to build, that is, to build an environmental project to be a step by step, a little bit of the ride, A lot of people come up and put the jar bag on the full guide, and then what configuration files Ah, all written or pasted from other places, and then a run, hang up ... Then all kinds of to find the problem, why bother? In this case, even if you build 10 times can not be handy. Eat a mouthful of food, the road to go step by step.
SSH environment to build, I personally follow the process is:
Spring–> hibernate–> Spring Consolidation hibernate–> struts2–> Spring consolidation Struts2
Each step to write a test class test, this is very important, because the next step down, the error also know where the wrong step, where to find the problem, the most important thing is that this process skilled, the next time to take the environment is easy. For more information about the SSH environment, see the following article:
Integrate Struts2, Hibernate4.3 and Spring4.2
Basic additions and deletions, retrieval of service and action, and substitution of XML with annotations
2. Build the Backstage management system
Background Management System I used the Easyui built, to be honest, easyui I am also a little knowledge, the front end of things I understand is not deep, but understand a point, the specific use of the time is also various to check, also did not learn the system, so there is no good knowledge system, but does not affect to play. Program apes like to say play a technology what, sounds like a very tall, slowly I also suffer some influence, also like to say, but I for the front end is really playing ...
The jquery Easyui is a collection of UI plug-ins based on jquery, and the goal of jquery Easyui is to help Web developers easily create a rich and aesthetically pleasing UI interface. Developers do not need to write complex JavaScript, and do not need to have a deep understanding of CSS styles, developers need to understand only a few simple HTML tags.
Easyui requests are AJAX requests, there is no new page out, all in the Tab tab or pop-up a window, and so on. Background management system is mainly divided into three parts: the category of commodity management, commodity management and sales management. Sales management at the end of the talk.
2.1 Management of commodity categories
This part mainly involves the construction of the EASYUI environment and the backstage frame, the cascading query and paging of the database, the DataGrid data display, the STRUTS2 integration JSON, and the additions, deletions, updates and searches of the commodity categories. This is also followed by a completion order for that part.
The DataGrid presents the data in tabular form, and the developer does not need to have specific knowledge to manipulate it, it has a good help document, and in this project I also introduced several ways to create a DataGrid, as well as a brief introduction to some of the properties of the DataGrid, As a primer, I am also a primer, a lot of development to master this technology.
The Add, delete, update, and search features of categories, the main is the use of Easyui with the verification function, add the category of goods, verify the input box input is correct, whether required to fill, etc; whether to select a row or a few lines at the time of deletion, update only one row at a time, all of these are AJAX requests.
For more information about this section, I have categorized it, please refer to these articles:
Using Easyui to build a background page frame
Implementation of Easyui Menu
cascading queries and paging for a database
Data display function based on DataGrid
Integration of STRUTS2 and JSON
DataGrid implements query and delete functions
DataGrid implements add and update features
Here are the problems I have encountered:
Lazy load exception problem in STRUTS2 and JSON integration
Hibernate4 Execution of Save () or update () is invalid
2.2 Management of commodities
The management of goods also has to add delete operations, and the type of management is the same, there is a place is the addition of goods, need to upload photos of goods, here involves the STRUTS2 implementation of File upload function, we need to build a folder on the server to store uploaded files, Then write a model to receive files, about file upload, to write a special tool class, project development is such, common code must be extracted, even if only a code to be extracted! It's a habit, and it has to be done. Details of these articles are listed below:
Building the basic module of commodity class
Query and delete the realization of the product function
Add and update the realization of the commodity function
Struts2 Implement file Upload function
3. Set up the foreground display page
Of course, the front page is not my design, this piece of content I summed up with the foreground display related to some background technology, such as: The Listener to get home data, Timer sync home data, hibernate two cache processing popular products, such as caching.
Before learning Serlvet, home page display data I did it, with a frame, the right display data, Then I jump to a servlet in the right-hand part of the index.jsp, and then the servlet goes to the database to take out all the items and put them in the request field with a new JSP page displayed in the past. This can be achieved, but very stupid. Here I used the listener to do this thing, first of all, I define a listener, in the event of the launch of the database all the merchandise information to take out, put into the application domain, and then the first page directly with El expression from the application domain to take it.
Another problem is that when I add a new product to the management system, I have to reboot Tomcat to add the new item to the application domain because it's been in the application domain for the first time, and it's dead. After the new addition is not in the application domain, in order to solve this problem, I used the timer to sync home data. So rewrite the previously written listener, set a timer in the listener, get the data of the merchandise in the database into the timer task, the first time to open immediately execute, and then execute every 6 hours (time can be arbitrarily set), that is, every 6 hours to regain the database of goods, to the application domain. The general website is also so dry, like Csdn's personal blog homepage is also, the daily update ranking, about 10 o'clock in the evening, I forget the specific time. At that time the refresh will see the data update, which also reduces the pressure on the server.
For the specific technical details of this section, see the following articles:
Use the listener to get the data displayed on the home page
How the listener gets spring's configuration file
Thread, timer timing sync Home data
Hibernate level two cache processing home page top display
4. Shopping Cart related functions
Part of the shopping cart mainly involves the technology: the background of the processing of shopping carts and shopping items of the logic, filter to determine the landing, order of the cascading storage and page caching problems.
Shopping cart words are mainly backstage some of the implementation of logic, shopping carts need to have shopping items, what do you mean? We know that we buy things on the day cat, we can put different products in the shopping cart, then there are a lot of goods in the shopping cart, the number of each product can be more than one, each product and its related information is a shopping item, so add a shopping cart, we first have to complete a shopping item, and then add this item to the shopping cart.
When the user wants to settle, we have to first judge the user has not landed, this use of filter technology, specifically filter a certain type of URL, in the filter to determine the current session there is no user object, if there is a description of the landing, direct release on the line, if not then jump to the landing page to allow users to log in, Landing completed to jump to the user originally want to go to the page. It's the same as the doorman ~ See the Gate ~
Just also mentioned, the order information contains shopping carts and shopping items, then we in the order warehousing, we must take into account their cascading issues, we can by the Pojo in both set the corresponding annotation attributes can be, but there is a prerequisite, like this has a foreign key association, Assign a value to the field in the foreign key portion of the corresponding Pojo before you enter the storage. For example, orders to add to the order item, the order in the item's attributes also have to assign a good value, and then you can give hibernate,hibernate according to the configuration of annotations (or XML files) together with their cascading warehousing.
Page caching problem refers to, when the user confirmed the order, if the point back, will return to the order confirmation page, just the order confirmation page came out again, and the session is still, information or just information, this is obviously not the result we want. We need to be in the foreground and backstage at the same time processing.
For specific technical details of this section, see the following articles:
Realization of basic function of shopping cart
The judgment of the filter to realize the landing function
Cascading warehousing and Page caching issues for order information
5. Online Payment function
This part mainly introduces some things about the Yeepay payment interface, in fact, the online payment function for different third parties are not the same, mainly to understand the online payment function development process, the specific technical details rely on the specific third-party information provided. But the general process is: Invoke the third party interface –> The third party calls the bank interface –> completes the payment –> the third party jumps to our specified page.
In this section, there is also an important technique that struts2 how to handle multiple model requests. General STRUTS2 Implementation of the modedriven<model> can be used in the action of the model, but now if there are two model how to do it? In the struts2, there is another call Parametersaware interface, as long as the implementation of this interface, and define a storage parameter map, you can receive all the parameters in request requests, we can according to different parameters to determine which model to use, This method can solve the problem of STRUTS2 processing multiple model requests well.
For technical details on this section, please refer to the following posts:
Introduction to Online payment platform
A demo of the Yeepay payment process
Get the display of the Bank icon and payment page
The logic of completing the online payment function
How to handle multiple model requests in STRUTS2
6. Mail and SMS delivery function
Send the message and send this part of the message is relatively simple, are some fixed API, will be used on the line, can not remember to check, I can not remember. The mail sends the function to import the Mail.jar package, then sends the mail according to the process, SMS function must first go to apply for a message to send the function, the application is good, the third party will give us some API interface, we only reference his can develop the text messaging function, with the payment function is a bit similar, are aided by the Third-party platform.
This part also does not have any technical difficulty, mainly is the flow bar, the related article is as follows:
Use Java email to send email to users
After the completion of the order to pay the success of the SMS delivery function
7. Application of domain name space and deployment release of project
This piece mainly introduced how to apply for a free domain name space (free 15 days only ~ But for the study, enough~), although not all free, but we are mainly to find out this process, go through it again, not necessarily upload the complete project, A JSP page or an HTML static page is OK.
There are two main ways to deploy and publish a project: One is the use of FTP upload, but this is slow, and there may be loss of data, personal experience is 1.1 point of hair; there is another way is to request a domain space where there will be a deployed environment, we just export the project as a war package, Then you can deploy the war package.
There are a lot of details to be aware of before a project is deployed, such as modifying some paths, modifying some data, and so on, which are described in detail in my blog. This section is on an article, as follows:
Application of domain name space and deployment release of project
8. Form validation and report display
Added to this is the AJAX dynamic update of the number of items in the cart, the verification of the form, and the display of the report.
Ajax Dynamic Update the number of items in the shopping cart is pure Ajax technology, I learned a little bit, the form of verification is mainly landing form, this project I did not do landing, but the landing form I did a, the verification function is done, the main use of jquery validate verification plug-ins, This plugin is still very powerful, you can directly add the landing form to the project, set up a corresponding jump can be. Report of the main use of the display is Jschart, this tool is very useful, you can generate a response to the JS code, we have to do is to send Ajax request to the background, according to the actual needs from the background to take out data, to the front desk with a Jschart chart to show it.
This section of the blog, which I listed to put in the following:
Local updating of product quantity and total price using AJAX technology
Jquery-validate Verify the use of the plug-in steps
Display merchandise Sales report in the background using Jschart technology
Online Mall This project is now written so much, csdn download channel source and my blog is synchronized, if you need to download my csdn in the source code (free ~ All my resources are free). If the latter is to continue to improve, I will be placed in my GitHub, but also welcome you to follow my GitHub (although generally like ~) Star I uploaded the project ~ below is the specific download address:
Download address (sync with blog content)
GitHub Download Address (later if any updates will be placed here)
Original address: http://blog.csdn.net/eson_15/article/details/51479994
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.