根路径上的Zuul路由 [英] Zuul Routing on Root Path

查看:206
本文介绍了根路径上的Zuul路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想配置zuul将请求路由到根/到主页.我试过了:

I want to config zuul to route request to root / to a home page. I tried:

root:
  path: /
  url: http://hostname/home/index.jsp

root:
  path: /**
  url: http://hostname/home/index.jsp

但是它们都不起作用.我刚找到404 Not Found.我认为路径匹配配置应与具有上下文的配置类似,例如/service/**,但不相同.

But neither of them works. I just got a 404 NOT FOUND. I think the path match config should be similar to those with contexts, such as /service/**, but it's not.

推荐答案

这就是我所做的工作.

在Zuul中->控制器:

Within Zuul -> controller:

@RequestMapping(value = "/", method = RequestMethod.GET)
public String handleRequest() {
    return "forward:/ux/";
}

Zuul属性:

zuul:
  addProxyHeaders: true
  routes:
    example-ux:
      path: /ux/**
      stripPrefix: false

在example-ux服务属性内:

Within example-ux Service properties:

server:
  servlet-path: /*
  context-path: /ux

此配置还解决了静态资源解析的问题.即/static/css static/js等...

This configuration also solves the problem of static resources resolution. i.e. /static/css static/js etc...

这篇关于根路径上的Zuul路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆