我想在我的JSP上使用下拉菜单,但是...我不知道如何捕获所选项的值并将其传递给我的Servlet,并有一些QUERY将值添加到我的数据库中。
你能给我一些想法或线索如何编码吗?
PS。 我还需要将下拉菜单中的项目转换为整数,因为我将把它添加到我的数据库中的存储数据中。
这对像我这样的初学者来说难吗? 我应该使用Textbox并让用户手动输入INTEGER而不是Dropdown菜单吗?
非常感谢提前:)
我的Jsp 菜单是这样的:
<body> <form action="AddPoints"> <table width="408" border="0"> <tr> <td width="402"><h3 align="center">Enter Points:</h3> <h3 align="center"> <label for="Points"></label> <select name="Points" size="1" id="Points"> <option value="5" selected>5</option> <option value="10">10</option> <option value="15">15</option> <option value="20">20</option> <option value="25">25</option> </select> <br/> </h3> <h3 align="center"><strong></strong> <input type="submit" name="AddPoints" id="AddPoints" value="Add Points"> </h3></td> </tr> </table> </form> </body>另外我想知道这一行的值 : <option value="25">25</option>是我的servlet可以捕获的实际值吗?
对不起,如果我有这么多问题...... :)
I want to use a dropdown menu on my JSP but... I have no idea how to capture the Value of the Selected Item and Pass it on to my Servlet and have some QUERY to add the value to my database.
Can you give me some idea or clue how to code it?
PS. I also need items at dropdown menu converted into an Integer cause i'll be adding it to the stored data at my database.
Will this be hard for a starter like me? should I use Textbox and let the user input an INTEGER manually instead of a Dropdown menu?
Thanks a lot in advance :)
My Jsp Menu is like this:
<body> <form action="AddPoints"> <table width="408" border="0"> <tr> <td width="402"><h3 align="center">Enter Points:</h3> <h3 align="center"> <label for="Points"></label> <select name="Points" size="1" id="Points"> <option value="5" selected>5</option> <option value="10">10</option> <option value="15">15</option> <option value="20">20</option> <option value="25">25</option> </select> <br/> </h3> <h3 align="center"><strong></strong> <input type="submit" name="AddPoints" id="AddPoints" value="Add Points"> </h3></td> </tr> </table> </form> </body>Also I am wondering if the value at this line: <option value="25">25</option> is the real value that my servlet can capture?
Sorry if i have so many questions... :)
最满意答案
int selectedItem; if(request.getParameter("Points")!=null) { selectedItem=Integer.ParseInt(request.getParameter("Points")); } int selectedItem; if(request.getParameter("Points")!=null) { selectedItem=Integer.ParseInt(request.getParameter("Points")); }更多推荐
value,菜单,电脑培训,计算机培训,IT培训"/> <meta name="description" co
发布评论