Create database and tables
(1) Database creation
1. Create database and user table
2. User added record
(2) Create a Maven project
(3) Add related dependencies
Add related dependencies to the pom.xml file
Open the Maven window, click the refresh button, and download dependencies
(4) Create a log attribute file
Create a log4j.properties file in the resources directory
(5) Create a database configuration property file
Create the jdbc.properties file in the recourse directory
(6) Adding Web functions to the project
Click the project Structure button on the toolbar
Click the Create-Artifact button
Rename the default SSMLogin.Web exploded to SSMLogin
WEB-INF
The subdirectories in the directory classes
contain the compiled bytecode files of source programs written by users, but jar
the packages that the project depends on need to create a lib
directory
Select all on the right Available Elements
, right-click, and a shortcut menu will pop up
Click Put into /WEB-INF/lib
the menu item to add the selected jar
package to /WEB-INF/lib
the directory on the left
(7) Configure the Tomcat server
1. Install the Tomcat server
Download tomcat-8.5.58.rar, extract it to the root directory of D drive
Enter the executable directory bin
Configure Tomcat environment variables
2. Start the Tomcat service
Execute in the command window: startup.bat, start the Tomcat service
In addition, a command line window will pop up, displaying Tomcat startup information
3. Visit the Tomcat home page
(1) The home page is in D:\tomcat-8.5.58\webapps\ROOT
the directory
(2) How does the client request (request) the dynamic web page placed on the serverindex.jsp
(3) The default port of the Tomcat server is 8080
, server.xml
which can be modified in the configuration file
4. Static resources
Create a py subdirectory in webapps
the directory and put some static resources in it
(8) Create a user entity class
Create net.py.ssm1.bean and create a User class in the package
(9) Create user mapper interface
Create net.py.ssm1.mapper, create UserMapper interface in the package
(10) Create a user service class
Create a service subpackage in net.py.ssm1, and then create a userservice class in the subpackage
(11) Create a user controller
Create a controller subpackage in the net.py.ssm1 package, and then create a usercontroller class in the subpackage
(12) Create a user mapper configuration file
Create a mapper subdirectory in resources, and then create usermapper.xml in the subdirectory
(13) Prepare static resources
1. Prepare image resources
Create an images directory in WEB-INF to store image resources-bear.png
2. Create a style file
Create a css subdirectory in WEB-INF, and then create login.css in the subdirectory
3. Create a script file
Create a js subdirectory in WEB-INF, and then create check.js in the subdirectory
(14) Create a page
1. Create a directory structure
Create the views subdirectory in WEB-INF, and create two subdirectories, frontend and backend, in views
2. Create the homepage of the website
3. Create a background management page
views/backend
created inmanagement.jsp
(15) Create a spring configuration file
resources
Create subdirectories inside , config
and then inside subdirectoriesspring-config.xml
(16) Create a springMVC configuration file
create in resources/config
directoryspring-mvc-config.xml
(17) Edit the Web deployment description file
(18) Start the server and check the effect
Set the <welcome-file>/WEB-INF/views/frontend/login.jsp <welcome-file> element in the culture, so the login page will be displayed first
non-null check
Login failed
Enter the correct username and password