Retrieving multiple textbox values with same name from JSP in Servlet

后端 未结 2 1327
悲哀的现实
悲哀的现实 2020-12-21 02:40

I am trying to pass values of textbox with same name from JSP to servlet but not able to accomplish this task.

I tried using this in servlet but i only get one text

相关标签:
2条回答
  • 2020-12-21 03:20

    If you have a form like that:

    <form method="post">
        <input type="text" name="words"><br>
        <input type="text" name="words"><br>
        <input type="submit">
    </form>
    

    Sends if you put one and two in the textboxs

    words=one&words=two
    

    For getting,

    String[] words = request.getParameterValues("words");
    
    0 讨论(0)
  • 2020-12-21 03:30

    You do not name the dynamically created input elements (to "words" or "meaning")

            var element2 = document.createElement("input");
            element2.name = "words";
            element2.type = "text";
            cell2.appendChild(element2);
    
    0 讨论(0)
提交回复
热议问题