why doesnt my jsp request.getParameter() get the data?

后端 未结 1 1065
遥遥无期
遥遥无期 2020-12-11 10:37

ive created a form in which user will check off checkboxes, select radio buttons, and drop downs in 1.jsp...

i want to use the information from 1.jsp to determine th

1条回答
  •  有刺的猬
    2020-12-11 10:46

    You seem to be expecting that the id attribute of the HTML input elements is been sent as request parameter name. This is wrong. It's the name attribute which is been sent as request parameter name. Its value is then the value attribtue which is been set on the named input element.

    So, instead of for example your incorrect check

    if(request.getParameter("extra") != null) {
        // ...
    }
    

    for the following radio button

    
    

    you need to get the parameter by name choice and test if its value is extranet.

    if ("extranet".equals(request.getParameter("choice"))) {
        // ...
    }
    

    As to the all checkbox, I am confused. It is possible to send the both values, yet you're checking them in an if-else. Shouldn't the all be inside the same radio button group? Shouldn't you remove the else? In any way, the point should be clear. It's the input elements' name attribtue which get sent as request parameter name, not the id attribute.

    0 讨论(0)
提交回复
热议问题