2024-07-12
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
The first step is to use the thymeleaf template engine in springboot
- <!-- thymeleaf 模板 -->
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-thymeleaf</artifactId>
- </dependency>
- spring:
- # 模板引擎
- thymeleaf:
- mode: HTML5
- encoding: utf-8
- # 禁用缓存
- cache: false
Enable access to static files in the configuration
- public class ResourceConfig implements WebMvcConfigurer {
- @Override
- public void addResourceHandlers(ResourceHandlerRegistry registry) {
- registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
- }
- }
npm run build
Put the static files in the static folder after packaging, and put index.html in the templates folder
Let it jump to the index.html page
- @Controller
- @CrossOrigin
- public class IndexController {
- @GetMapping("/")
- public String index(){
- return "index";
- }
- }
Enter the port and access it!