Chapter 11 --- spring project online store small project summary

Simple step by step learning spring feeling a bit slow, two days to learn some basic springMVC use, such as RequestMapping, parameter accepts, Json data processing, format conversion, file upload and download, blocker, filter, static resource file handling, exception processing and other basic functions, a function to achieve, it is better to look at the project from a more three-dimensional look. So then we'll do a small project to specific learning. Before learning, we first look at the past two days I see the entire execution process know SpringMVC

Following is a brief dispatch posted way back function can click to view the specific method.

    // 调用我们的dispatcher中进入分发
    protected void doDispatch(HttpServletRequest request, HttpServletResponse response) throws Exception {
    HttpServletRequest processedRequest = request;
    HandlerExecutionChain mappedHandler = null;
    boolean multipartRequestParsed = false;
    WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(request);

    try {
        try {
            ModelAndView mv = null;
            Object dispatchException = null;

            try {
                processedRequest = this.checkMultipart(request);
                multipartRequestParsed = processedRequest != request;
                // 获取handleExecutionChain对象
                mappedHandler = this.getHandler(processedRequest);
                if (mappedHandler == null) {
                    this.noHandlerFound(processedRequest, response);
                    return;
                }

                // 获取适配器对象
                HandlerAdapter ha = this.getHandlerAdapter(mappedHandler.getHandler());
                String method = request.getMethod();
                boolean isGet = "GET".equals(method);
                if (isGet || "HEAD".equals(method)) {
                    long lastModified = ha.getLastModified(request, mappedHandler.getHandler());
                    if ((new ServletWebRequest(request, response)).checkNotModified(lastModified) && isGet) {
                        return;
                    }
                }
                //Call interceptor PreHandle method, a for loop is executed inside all the interceptors PreHandler method, the order of execution
                 // inside the for loop for (int I = 0; I <interceptors.length; this.interceptorIndex = I ++) 
                IF (! MappedHandler .applyPreHandle (processedRequest, Response)) {
                     return ; 
                } 

                // Get ModelAndView object 
                Music Videos = ha.handle (processedRequest, Response, mappedHandler.getHandler ());
                 IF (asyncManager.isConcurrentHandlingStarted ()) {
                     return ; 
                } 

                the this .applyDefaultViewName ( processedRequest, mv);
                 //Call interceptor PostHandler method, performed inside PostHandler method, the loop which is executed for all the interceptors PostHandler method, but the reverse is performed
                 // inside the for loop for (int i = interceptors.length - 1 ; i> = 0 ; Inc. (www.i-levelmedia.com)) 
                mappedHandler.applyPostHandle (processedRequest, Response, Music Videos); 
            } the catch (Exception var20) { 
                dispatchException = var20; 
            } the catch (the Throwable var21) { 
                dispatchException = new new NestedServletException ( "dispatch Handler failed" , var21); 
            } 


            the this .processDispatchResult (processedRequest, response, mappedHandler, mv, (Exception) dispatchException);
        } The catch (Exception var22) {
             the this .triggerAfterCompletion (processedRequest, Response, mappedHandler, var22); 
        } the catch (the Throwable var23) {
             the this .triggerAfterCompletion (processedRequest, Response, mappedHandler, new new NestedServletException ( "Processing Handler failed" , var23)); 
        } 

    } the finally {
         IF (asyncManager.isConcurrentHandlingStarted ()) {
             IF (mappedHandler! = null ) {
                 // final execution afterCompletion interceptor, which is also for this loop, execution reverse
                 // for (int I = interceptors.length -. 1; I> = 0; Inc. (www.i-levelmedia.com) )
                mappedHandler.applyAfterConcurrentHandlingStarted(processedRequest, response);
            }
        } else if (multipartRequestParsed) {
            this.cleanupMultipart(processedRequest);
        }

    }
}

Next, a simple look at the basic realization that we want to write a small shopping mall project, below is a flow chart

 

I'm going to do that this project will be divided into several small modules, a user module, a module is an order, a shopping center module is currently envisioned two databases used:

1. redis record user login information, valid for the day shopping cart information changes more general, because it is a small project, it put redis.

2. myql recorded data.

It is expected to use the technology mainly includes: SpringMVC, JQuery, JDBC, mysql, redis, bootstrap

That we are going to design a database, simple four tables, is expected to meet our needs

Use tool intillij, create a project javaEE web project, currently anticipated project structure as shown below.

Guess you like

Origin www.cnblogs.com/yangshixiong/p/12207792.html