How to remove trailing slash from embedded Jetty URLs?

时光总嘲笑我的痴心妄想 提交于 2019-12-05 18:19:21

The way you have defined your Contexts is the reason for that.

A ContextHandler is a "root" to a set of resources, and that root is defined to always be a resource directory (in structure).

Since you defined ContextHandler("/api/accounts") and accessed /api/accounts the implementation "helps" you by making /api/accounts/ the correct Context root.

Imagine this ...

  • You have val b = ContextHandler("/a/b")
  • You have val a = ContextHandler("/a") - which implements (internally) support for sub-resource /b
  • If you request /a/b, which context are you in? - Per spec, you are in context a
  • If you request /a/b/, then you are in context b
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!