Skip to content

StudentsAdministration/03_my_first_website

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 

Repository files navigation

My First Website

After creating an empty new Spring project in IntelliJ through the Spring Initializer Template: #3 Hello Spring, you should now create your first Hello World Website.

Remember that this is a step by step instruction. It does not explain all the concepts in details. This explanaition you will get from your teacher in class.

You should now have a folder and file structure that looks something like this:

If you open your src folder you will see a main and a test folder.
Delete the:

  • test folder
    And delete the:
  • mvnw and the mvnw.cmd files.

(you could leave them in the project, but since we are not going to use them we delete them for a better overview)

Now you have a project structure that looks like this:

Create a normal java class file

In the demo folder create a class and call it HomeController.java.

  • Right click the "demo" folder
  • chose: New -> Java Class
  • Name: HomeController
  • Kind: Class

Create an index method in the class

Create a public method called index with a return type of String, and return the string "index".

Add @Controller above the class definition and @GetMapping("/") above the method definition.

Create an index.html file

  • right click resource -> template folder
  • Choose: New -> html file
  • Name: index
  • Kind: Html 5 file
  • Delete the <meta charset="UTF-8"> tag
  • Add xmlns:th="http://www.thymeleaf.org"  to the  <html lang="en"> tag

Make your code look like the image above. (do your best :))

Run the application

push the green start button in the upper right corner.

Open your browser and type http://localhost:8080

About

Getting started with spring on 2. semester

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published