gpt4 book ai didi

java - 无法找到规范上下文路径与用户代理提供的 URI 之间的匹配项

转载 作者:行者123 更新时间:2023-11-28 23:11:44 28 4
gpt4 key购买 nike

我在部署在 tomcat 容器中的本地系统中运行一个 spring boot 应用程序。一切正常。但是当将相同的代码部署到服务器时,它显示 URL 异常 -

例如,如果项目上下文路径是 xyz -

http://localhost:8080/xyz;id/没有给出任何错误,但在服务器中相同(https://server/xyz;id/)抛出 500 错误如下 -

我还尝试编写一个 Controller 来处理“/error”路径,因为错误是通过 ErrorPageFilter.java 路由的。但这没有用。

异常堆栈跟踪 -

java.lang.IllegalStateException: Unable to find match between the canonical context path [/httpsportal] and the URI presented by the user agent [/httpsportal;id/]
org.apache.catalina.connector.Request.getContextPath(Request.java:1958)
org.apache.catalina.connector.RequestFacade.getContextPath(RequestFacade.java:783)
org.springframework.boot.web.support.ErrorPageFilter.forwardToErrorPage(ErrorPageFilter.java:183)
org.springframework.boot.web.support.ErrorPageFilter.handleException(ErrorPageFilter.java:166)
org.springframework.boot.web.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:130)
org.springframework.boot.web.support.ErrorPageFilter.access$000(ErrorPageFilter.java:59)
org.springframework.boot.web.support.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:90)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.springframework.boot.web.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:108)

预期路由回“/xyz”或重定向到“/error”页面。但是什么都没有发生。

请注意,/xyz;id 正在转换为/xyz,但在最后保留斜线,即/xyz;id/会引发错误(在服务器中)。

最佳答案

发现服务器 tomcat 版本 v8.0.20 存在问题

一旦将 tomcat 版本升级到某个更高版本,问题就不可重现了。

关于java - 无法找到规范上下文路径与用户代理提供的 URI 之间的匹配项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57077708/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com