gpt4 book ai didi

java - Http request.getParameter( fieldname ) 与 List

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

我看到如果 html 中的条目表单有一个输入类型 = 文本 ...我可以使用

将此文本读取为字符串
request.getParameter( fieldname ).

但是如果选择是多个,我如何读取列表?

我想根据多个参数在 bean 中设置一个 ArrayList。像这样

List<String> values = request.getParameter( fieldsList );

最佳答案

我想你在找getParameterValues :

获取参数值

String[] getParameterValues(String name) Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist. If the parameter has a single value, the array has a length of 1.

Parameters: name - a String containing the name of the parameter whose value is requested Returns: an array of String objects containing the parameter's values See Also: getParameter(java.lang.String)

关于java - Http request.getParameter( fieldname ) 与 List,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21658621/

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