简体   繁体   中英

Send data from an HTML select to a Servlet

I have a scheduleMeet.jsp page

<select name="Dept">
    <option value="Personalization">Personalization</option>
    <option value="WebDevelopment">WebDevelopment</option>
    <option value="MobileApp">MobileApp</option>
</select>
<input type="submit"/>

And I want to send the data when the user selects one of the option from dropdown to a servlet.

Can someone suggest code snippet for the Servlet?

String Department= request.getParameter("Dept");

So you will get data from one of option's value. If you don't believe it, you can print out the Department object like:

System.out.println(Department);

您可以使用进行多种选择:

String[] assignedResources = request.getParameterValues("Dept");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM