gpt4 book ai didi

java - 正在 http 发布文件,如何通过索引引用参数?

转载 作者:行者123 更新时间:2023-12-02 08:05:19 27 4
gpt4 key购买 nike

一个 XML 文件被发布到我的 spring mvc 正在响应的 URL。

在 .NET 中,我可以这样做:

request.Form[0]
request.Form["abc"]

request.QueryString[0]
request.QueryString["some_key"]

现在使用 spring/servlet 似乎我只能这样做:

request.getParameter("some_key")

或获取所有名称或值。

当有人使用 http post 将文件发布到 url 时,这不只是一个请求参数吗?

我可以使用 servlet 的索引来获取参数吗?

最佳答案

When someone is posting a file to a url, using http post, won't this be just a single request parameter then?

不一定。如果表单包含更多字段,那么我们就会有更多参数。

Can I get the parameter using index with servlets?

据我所知,不。request.getParameter() 不返回数组或集合。所以不能用 request.getParameter()

做到这一点

request.getParameterValues(String) 返回一个数组 - 但仅返回与给定参数名称关联的值

request.getParameterMap() 适用于键,而不是有序的。这也无济于事。

关于java - 正在 http 发布文件,如何通过索引引用参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8279643/

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