1. Create a static package in the original project resouces directory, and create pages under static, and then hello.html under the pages package.
At this time, you will find that hello.html is not in static. Where did it go? Open the webapp under src and find that there is a hello.htm, delete the web.xml, and move hello.html to the static directory with the left mouse button;
hello.html code:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"/> <title>Insert title here</title> </head> <body> <h1>springboot access the first html page</h1> </body> </html>
1.1. Create springboot configuration file application.roperties
Create application.properties, After the creation is completed, a green leaf icon will appear.
Open application.properties and add the following configuration:
spring.mvc.view.prefix=/pages/ spring.mvc.view.suffix=.html
1.2. Modify the code in SpringBootController
Will
Change to
1.3. Test
Start the main method in Appliction (the entry of springboot application)
Open the browser to visit http://localhost:8080/hello
Effect:
Summarize
The above is a detailed explanation of the Springboot access html page tutorial introduced to you by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support to Wulin.com website!