Web template language – Thymeleaf
thymeleaf
Project launch, and each page entry
The project address
tinytongtong/spring-thymeleaf
Step 1 Project operation:
Open the IDE and execute the EurekaServerApplication.
Access Interface – Browser direct access
Eg: get request: http://localhost:8201/api/execute/get
http://localhost:8201/api/execute/get?name=maolegemi
Accessing web Pages
To access static pages:
http://localhost:8201/static.html
Visit dynamic page:
1. Visit the Index page
http://localhost:8201/index
2. Access the Basic-Usage page
http://localhost:8201/basic-usage
3. Visit the Request-Methods page
http://localhost:8201/request-methods
The project architecture
Application entry class -EurekaServerApplication
Start the class to start the service.
Web pages correspond to WebControllers
API interfaces correspond to ApiController
Static Web pages
Resources /static/ Resources in the directory
Web dynamic pages
Resources /template/ resources
Web dynamic page configuration
SpringBoot use thymeleaf, specific see project root directory/SRC/main/resources/appliaction yml `.
How to create a new page
New HTML file
Create a new HTML file in the resources/template/ directory.
<! DOCTYPE html> <html lang="en" xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="UTF-8"> <script Th: SRC = "@ {/ webjars/jquery / 3.1.1 / jquery. Min. Js}" > < / script > < script Th: SRC = "@ {/ webjars/bootstrap / 3.3.7-1 / js/bootstrap. Min. Js}" > < / script > < title > title < / title > < / head > < body > < div > < / div > <script> </script> </body> </html>Copy the code
For the first time, you need to add this URI to the configuration:
Under the project#dependencies/dependency tag of pum.xml:
Webjars </groupId> <artifactId>bootstrap</artifactId> <version>3.3.7-1</version> </dependency> Webjars </groupId> <artifactId>jquery</artifactId> <version>3.1.1</version> </dependency>Copy the code
Add routing methods to WebController
[Img-uza3UKXP-1632454296979] (EvernotecID :// 5e413247-DCB6-499B-8453-f2a2C2DF33A4 /appyin Xiangcom / 13182898 / ENResource/p17197)] and then add
/** * Local access content address: http://localhost:8201/request-methods * * @param map * @return */ @RequestMapping("/request-methods") public String RequestMethods (HashMap<String, Object> map, Model Model) {model.addattribute ("get111", "I am get method "); return "request-methods"; // HTML page name -request-methods.xml}Copy the code
How to Jump to a Page
By relative routing address:
<button onclick="window.location.href='/request-methods'"> </button>Copy the code
How to send a request – Ajax
Ajax requests should be sent inside the page.
AJAX – Liao Xuefeng
Port Occupation problem
Checking port Usage
lsof -i:8201
Copy the code
Shut down the current port process
kill -9 pid
Copy the code