Order of request.getParameterNames()

后端 未结 5 1035
无人共我
无人共我 2021-01-04 04:36

How do I get all the parameterNames in an HTML form in the same sequence as they are in the form.

i.e if the form contains .... FirstName, LastName, MiddleName and

5条回答
  •  说谎
    说谎 (楼主)
    2021-01-04 04:57

    Updated: U can user sorted set for that. note that u must have all the parameter with different name. (in this case it is most likely) Write any pref.ix as your parameter name for ex.

        
        
    

    and so on...

    then in java code you can write

        SortedSet ss = new TreeSet();
         Enumeration enm=request.getParameterNames();
        while(enm.hasMoreElements())
        {
            String pname = enm.nextElement();
        }
                Iterator i=ss.iterator();
                while(i.hasNext())
        {
            String param=(String)i.next();
            String value=request.getParameter(param);
        }
    

提交回复
热议问题