首页 > 解决方案 > 如何正确测试转发任何未映射的路径?

问题描述

我正在做一个在 jhiptser 上的微服务中实现的项目,我对这两个主题都很陌生。网关应用程序在 Angular 中运行。本应用使用了HashLocationStrategy,但由于需要通过Linkedin集成鉴权,所以将位置策略改为PathLocationStrategy。原因是 Linkedin 应用程序不接受#所需回调 url 中的哈希值。我现在面临的问题是,在导航到某个路线然后刷新后,我在屏幕上收到一个带有消息的 404:Cannot GET /reset/

我已经阅读了它,并且我知道我需要在服务器端进行修改。具体如下:

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class ClientForwardController {

    /**
     * Forwards any unmapped paths (except those containing a period) to the client {@code index.html}.
     * @return forward to client {@code index.html}.
     */
    @GetMapping(value = "/**/{path:[^\\.]*}")
    public String forward() {
        return "forward:/";
    }
}

如何在我的开发环境中进行测试?

现在我运行正在运行的应用程序,npm run start我重现了所描述的内容,当我刷新时,我收到了消息Cannot GET /reset/request

提前致谢

标签: angularjhipster

解决方案


推荐阅读