Zuul Routing on Root Path

有些话、适合烂在心里 提交于 2019-12-08 07:18:55

问题


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

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

and

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

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.


回答1:


This is what I have done to make this work.

Within Zuul -> controller:

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

Zuul Properties:

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

Within example-ux Service properties:

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

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



来源:https://stackoverflow.com/questions/38986500/zuul-routing-on-root-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!