0
@RequestMapping("/api/**")
public ApiResult api(HttpServletRequest request, HttpServletResponse response){
    return apiProxy.proxy(request, reponse);
}

@RequestMapping(value="/**", method=HTTPMethod.GET)
public String index(){
    return "index"
}

Ant Design Pro的文档时候这么介绍的,问题是 ApiResult apiProxy代码是怎么样的呢?

2019-02-11 提问
2 个回答
0

已采纳

https://github.com/ant-design... 解决方法:

解决browserHistory构建完成后直接放到Spring Boot 项目的resource/static目录下面,浏览器在其他路径刷新或者直接访问无法加载视图的方法。
找到一个非常简单的方法了,使用ErrorController和修改application.properties文件:
application.properties添加:

spring.mvc.view.suffix=.html

Java代码:

import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class AntDesignController implements ErrorController {
    @Override
    public String getErrorPath(){
        return "/error";
    }

    @RequestMapping(value = "/error")
    public String getIndex(){
        return "index"; //返回index页面
    }

}

Kotlin代码

import org.springframework.boot.web.servlet.error.ErrorController
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.RequestMapping

@Controller
class AntDesignController: ErrorController {
    @RequestMapping("/error")
    fun getIndex():String{
        return "index"
    }
    override fun getErrorPath(): String {
        return "/error"
    }
}

撰写答案

推广链接