0% found this document useful (0 votes)
3 views7 pages

Java Spring Boot Web Development Guide

This tutorial provides a step-by-step guide to developing a Java web application using Spring Boot, focusing on system authentication, data validation, and web templates with Thymeleaf. Key tasks include setting up a Spring Boot project, configuring MySQL, creating models and controllers, and implementing user interfaces with error handling. Additional tasks involve enhancing the application with user registration, role-based authorization, and image upload functionality.

Uploaded by

tuan phuong
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views7 pages

Java Spring Boot Web Development Guide

This tutorial provides a step-by-step guide to developing a Java web application using Spring Boot, focusing on system authentication, data validation, and web templates with Thymeleaf. Key tasks include setting up a Spring Boot project, configuring MySQL, creating models and controllers, and implementing user interfaces with error handling. Additional tasks involve enhancing the application with user registration, role-based authorization, and image upload functionality.

Uploaded by

tuan phuong
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

TUTORIAL 8 – DEVELOP JAVA WEB

WITH SPRING BOOT (2)

❖ Content:
▪ Setup system authentication (login/logout) using Spring Security
▪ Make data validation using Hibernate Validator and display form input
error using Thymeleaf
▪ Establish web template using Thymeleaf layout dialect
❖ Instructions:
1. Create new Java Spring Boot project with dependencies (Refer to Tutorial 7)

Figure 2 - Project dependencies

Figure 1 – Sample project structure


2. Setup automatic reload static web page (HTML + CSS files)
- File  Settings (Ctrl + Alt + S)

Figure 3 – Setup automatic reload web page (1)

Figure 4 - Setup automatic reload web page (2)

3. Config MySQL connection, JPA & Hibernate, Thymeleaf (Refer to Tutorial 7)


▪ Config default login information (authentication) & server port (optional)

Figure 5 - [Link]
4. Add Thymeleaf layout dependency manually in file [Link]

Figure 6 - [Link]

5. Create Java class for model (entity) which acts as table in database (Refer to
Tutorial 7)
▪ Update code for data validation

Figure 7 - [Link]

6. Create Java interface which extends JpaRepository (Refers to Tutorial 7)


7. Create Java class for controller which gets data from database and renders view
(Refers to Tutorial 7)
▪ Update value for @RequestMapping annotation

Figure 8 - @RequestMapping
▪ Update code for saveUpdate() method to show the form input error

Figure 9 - saveUpdate() method

8. Create HTML pages with Thymeleaf as view (Refers to Tutorial 7)


▪ Add a web template (_layout.html)

Figure 10 - _layout.html
▪ Add homepage ([Link])

Figure 11 - [Link]

▪ Add Thymeleaf code to display error on form input

Figure 12 - [Link]

▪ Create CSS file ([Link]) to format the input error

Figure 13 - [Link]
9. Run the web application with a web browser

Figure 14 – Login page

Figure 15 – Homepage with navigation

Figure 16 - Employee list with Add, Update & Delete features


Figure 17 – Add employee with input validation

Figure 18 – Logout page

❖ TASKS:
▪ Complete the remained codes to run web application
▪ Add more entity attributes with corresponding validation then update codes
in Add & Edit forms to show errors
▪ Create user registration page
▪ Change login form interface
▪ Add other accounts with roles then setup authorization (such as admin can
add, edit, delete but standard user can only view)
▪ Upload image by local file instead of using URL
• Compress the whole project and submit to FIT LMS with file name syntax:
FullName_StudentID_SE1_Tut8.zip

You might also like