Create New Page

Spring Boot
How to add a New Page:
  • Create New View {filename}.html in src\main\resources\templates Folder.
  • Create Controller for different methods related to page. (Optional. You can use default controller also.)
  • Set path in method of controller file to serve the page on the browser.
  • Add attribute layout:decorate="layout" in html tag for vertical menu
  • Add attribute layout:decorate="layout-horizontal" in html tag for vertical menu

Steps to add a new page :

  • Step 1: Create a file with the test.html under the src/main/resources/templates directory. Let's create a test Page for an example with filename test.html and placing the below code in that file.

  • <html layout:decorate="~{'layouts/' + ${template}}">
    <head>
    <title th:text="${title} +' | Skote - Admin & Dashboard Template'"> </title<
    </head>
    <th:block layout:fragment="pagecss">
    </th:block>
    <body>
    <div layout:fragment="content"> ... </div>
    <th:block layout:fragment="script">
    </th:block>
    </body>
    </html>


  • Step 2: To add new class, , use below step :

    Right Click on project root folder and select new in context menu and select class.

    @Controller
    public class testController {
    @GetMapping("/test")
    public String test(Model model) {
    return "test";
    }
    }


  • Step 3: After creating file and class and you want page to be serve on the url http://localhost:8080/test

After completing these above steps you need to run the project . It will serve your app on the localhost.

© Themesbrand.
Crafted with by Themesbrand