SSM Application (4)--Introduction to SpringMVC

The concept of SpringMVC

  It is a web layer framework, which is essentially a huge servlet;

  All requests will be sent to the SpringMVC servlet: @WebServlet("/");

  All responses are issued by SpringMVC;

  SpringMVC distributes requests to corresponding Java classes;

  SpringMVC container: manages many instances of Java classes and distributes requested objects;

  Web: used to handle jumping and data transfer issues;

  How to use SpringMVC

    First, you need to introduce the Jar package required by SpringMVC, download address: http://repo.spring.io/release/org/springframework/spring/

    Configure the SpringMVC servlet and configure it as a servlet in web.xml;

     

      SpringMVC is a Servlet that receives *.action requests;

 

     Configure the core configuration file of SpringMVC;

      The core configuration file of SpringMVC is essentially a Spring configuration file; an instance of the bean needs to be found;

      Tell DispatcherServlet where the core configuration file to use is;

    

 

    What needs to be configured in the core configuration file:

      Request line:

        SpringMVC itself is a Spring concept: managing the relationship between beans and beans;

        The SpringMVC servlet needs to find a common Java class (bean)

      Response line:

        View correspondence: SpringMVC gives a logical view - it needs to be converted to a physical view

        There are many kinds of responses returned, and the physical view is found through the logical view (similar to the key-value pair method)

        View resolver:

 

  The class that implements the control layer managed by SpringMVC: Controller;

    is a normal Java class for SpringMVC to dispatch requests

     

    Through package scanning, the HelloController class will become a bean instance that SpringMVC can directly use

       

    Through view parsing, the return value result will be parsed as: /result.jsp;

 

PS: Due to the limited ability of the author, please forgive me if there are any mistakes;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325112319&siteId=291194637