Get all parameters from JSP page

后端 未结 6 1360
无人共我
无人共我 2020-12-01 03:33

I have n number of text fields named in the form \"Question.....\". How can I get all the parameters which starts with \"question\" from the JSP page to the Action?

6条回答
  •  栀梦
    栀梦 (楼主)
    2020-12-01 04:16

    This should print out all Parameters that start with "Question".

    
    <%@ page import = "java.util.*" %>
    Parameters:
    <% Enumeration parameterList = request.getParameterNames(); while( parameterList.hasMoreElements() ) { String sName = parameterList.nextElement().toString(); if(sName.toLowerCase.startsWith("question")){ String[] sMultiple = request.getParameterValues( sName ); if( 1 >= sMultiple.length ) // parameter has a single value. print it. out.println( sName + " = " + request.getParameter( sName ) + "
    " ); else for( int i=0; i" ); } } %>

提交回复
热议问题