功能管理,完成
This commit is contained in:
26
src/main/java/com/cczsa/xinghe/codegen/config/WebConfig.java
Normal file
26
src/main/java/com/cczsa/xinghe/codegen/config/WebConfig.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.cczsa.xinghe.codegen.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* @author xia
|
||||
* @date 2026/1/20
|
||||
* @version 0.0.1
|
||||
*/
|
||||
@Configuration
|
||||
public class WebConfig implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addViewControllers(ViewControllerRegistry registry) {
|
||||
// 将所有非 API 的路径转发到 index.html
|
||||
// 注意:这里假设你的 API 请求都有 /api 前缀
|
||||
registry.addViewController("/{path:[^\\.]*}")
|
||||
.setViewName("forward:/index.html");
|
||||
|
||||
// 针对多级路径的递归处理(可选)
|
||||
registry.addViewController("/**/{path:[^\\.]*}")
|
||||
.setViewName("forward:/index.html");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user