Tell you to learn to use the Spring framework to write the basic [student information management system] (2) (continuously updated)

Project series directory:

Tell you to learn to use the Spring framework to write the basic [Student Information Management System] (1)

Tell you to learn to use the Spring framework to write the basic [Student Information Management System] (2)

Tell you to learn to use the Spring framework to write the basic [Student Information Management System] (3)

Tell you to learn to use the Spring framework to write the basic [Student Information Management System] (4)  

Tell you to learn to use the Spring framework to write the basic [Student Information Management System] (5)


Table of contents

1. Convert Maven project to Web project

 The specific steps to convert a Maven project into a Web project are as follows:

 2. Operation of the project

"Follow-up content is being continuously updated! ! ! "


         In the previous issue, we explained the expected effect of the project and how to create a Maven project, and also imported the MySQL jar package. Following the project creation steps in the previous issue, we continued to improve the project.

1. Convert Maven project to Web project

        The main reason why you want to convert a Maven project into a Web project is to understand the difference between the two projects. The difference between the two is divided into three aspects:

        The first aspect is that the definitions of the two are different:

        Maven is not only a build tool, but also a dependency management tool and project information management tool;

        Web projects are coding projects for web pages that need to be run on a server.

        The second aspect is that the functions of the two are different:

        Maven is composed of project object model, standard collection, project life cycle and dependency management system. It can manage project construction, reporting and documentation through project object model description information, and can also generate sites and manage JAR files;

        Web is a network service built on the Internet, including hypertext, hypermedia and hypertext transfer protocol, which can provide a graphical and intuitive web browsing interface, and information can be updated in real time.

       The third aspect is that the characteristics of the two are different:

        Maven has a life cycle, which is called when you run mvn install. This command tells Maven to perform a series of ordered steps until it reaches the life cycle you specify. One effect of the journey through the lifecycle is that Maven runs a number of default plugin goals that do things like compile and create a JAR file.

        The Web is the Global Wide Area Network, also known as the World Wide Web, which is a global, dynamic interactive, cross-platform distributed graphic information system based on hypertext and HTTP. It is a network service built on the Internet, which provides a graphical, easy-to-access and intuitive interface for viewers to find and browse information on the Internet.

        The specific steps to convert a Maven project into a Web project are as follows:

        Click File->Project Structure in the upper right corner, then click Project on the right navigation bar to enter the corresponding interface, pay attention to the marked in the figure below, see the output directory of the project operation, which is out, and then click the OK button.

        ​​​​Then continue to click the Modules button on the right navigation bar, click the + sign, and click Create Web Module.

        After clicking Create Web, pay attention to the location marked in the figure below. The path must be correct. Pay attention to the following four situations. After all are completed, click the OK button at last.

        Note 1 : Don’t worry about the web2 in the path marked with the mathematical symbol ① in the picture. This happened because my project was built for the second time. The path name of the first created Web project is web ! Just pay attention here, it does not have to be exactly the same as the name on the picture, but the final web.xml file must be the same! ! !

        Note 2 : The location marked ② in the figure below needs to point to the resources directory !

        Note 3 : For the position marked ③ in the figure below, you need to check the two boxes in the figure.

        Note 4 : The position marked ④ in the figure below is to create a package directly. After finishing the above, just click and the package will be created automatically.

         Then click the Artifacts button with a century-old navigation bar, click the + sign, and select Web Application: Exploded-->From Modules.

 ​​​​​

        In the pop-up window, click the OK button. 

After clicking OK, see if there is a web folder in your i project directory:

         At this point, the project really becomes a Web project! ! !

 2. Operation of the project

        The Web project has been created, and the next job is to configure Tomcat to run the entire project successfully.

         Click the Add... button in the upper right corner:

 In the pop-up window, click the + sign, click Tomcat Server-->Local.

 

         Click the ① logo position and ② logo position-Fix button in the above picture:

         Modify your own Tomcat path and so on. (Just modify it yourself here, it's very simple, so I won't say more).

        Mark the corresponding interface of the ② button: After clicking Fix, click the war one in the pop-up dialog box ( note: the position marked by the rectangular box in the following figure will be displayed by itself after clicking war, so try not to change it! ) , and then return to the Server interface.

 

         After returning to the Server interface, pay attention to modify the six places identified in the figure below, and then click the OK button:

         Among them, it should be noted that:

  • ① The location is the running browser!
  • ②The location is the path URL of the operation!
  • ③ and ④ positions are hot start--that is, the code has been modified, and the result can be seen without restarting the server!
  • ⑤ and ⑥ are port numbers!

         Then click the resources folder in the project file directory, right-click to create a login.html file, the steps are as follows:

         Click on the web.xml file and enter the following code:

<welcome-file-list>
        <welcome-file>login.html</welcome-file>
    </welcome-file-list>

         Edit the login.html file. Now let’s create a simple interface to test whether the project can run correctly.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>spring学习系统</title>
</head>
<body>
这里是学习系统login界面!!!
</body>
</html>

         Click the run button in the upper right corner to run the project with Tomcat (it takes a long time to run, please be patient!):

         So far, a simple project has been created and it can run correctly! ! We will continue to write the content of the project in the next issue. Thanks for watching! ! !

"Follow-up content is being continuously updated! ! ! "

Please bookmark and follow to not get lost! ! !

Guess you like

Origin blog.csdn.net/m0_56417836/article/details/127191121