You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Jetty 12.0.3对无尾斜杠请求返回301(原Jetty11为302),是否可配置?

Jetty 12与Jetty 11无尾斜杠URL重定向状态码差异及配置疑问

问题描述

向无尾斜杠的URL发送POST和GET请求时,Jetty 11.0.7返回302重定向,但Jetty 12.0.3返回301重定向。浏览器访问时无此问题,因为浏览器会自动为URL添加尾斜杠。需确认该行为是否可配置。

环境详情

  • 使用Jetty Docker镜像:jetty:12.0-jdk17,Jetty 12.0.3存在此问题
  • 部署的Web应用为frqa(WAR包形式),已应用过滤器

配置信息

RUN cd /var/lib/jetty && \
    java -jar $JETTY_HOME/start.jar --create-startd && \
    java -jar $JETTY_HOME/start.jar --add-modules=ee8-deploy,ee8-jsp

补充说明

POST和GET请求在Jetty 12.0.3中均返回301,而Jetty 11.0.7中均返回302。

请求示例

符合预期(Jetty 11.0.7)

$ httpie --verbose --all http://ding.bat.org:8050/frqa/
GET /frqa/ HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: ding.bat.org:8050
User-Agent: HTTPie/2.4.0



HTTP/1.1 302 Found
Cache-Control: max-age=0, no-cache, no-store, must-revalidate
Content-Length: 0
Expires: Sat, 01 Jan 2000 01:00:00 GMT
Location: http://blah.afb.com:8010/blah/oauth2/authorize?

不符合预期(Jetty 12.0.3)

$ httpie --verbose --all http://ding.bat.org:8050/frqa
GET /frqa HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: ding.bat.org:8050
User-Agent: HTTPie/2.4.0



HTTP/1.1 301 Moved Permanently
Content-Length: 0
Location: /frqa/
Server: Jetty(12.0.3)

内容的提问来源于stack exchange,提问作者Edward Barker

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.01 11:01:11