gpt4 book ai didi

java - Spring MVC - 什么是 url 路径信息?

转载 作者:行者123 更新时间:2023-12-01 08:15:15 24 4
gpt4 key购买 nike

我想知道什么是 url 路径信息?

例如

http://myserver:8080/servletname/handlermethod

是否是包含服务器名称的整个路径:

http://myserver:8080/servletname/handlermethod

或者只是

/servletname/handlermethod

最佳答案

getPathInfo() 根据文档:

Returns any extra path information associated with the URL the client sent when it made this request. The extra path information follows the servlet path but precedes the query string and will start with a "/" character.

因此在您的示例中它将返回 /handlermethod

如果您想要/servletname/handlermethod,您应该使用getRequestURI()

getRequestURL() 将返回客户端创建的完整 URL(字符串参数除外)。

关于java - Spring MVC - 什么是 url 路径信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13921666/

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