这是我的jsp
<form action = "first" > <!-- first servlet -->
<select name="loginAs">
<option>Fan</option>
<option>Club Member</option>
<option>Admin</option>
</select>
</form>
这是我的仆人:
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
String c = req.getParameter("loginAs");
}
但是当我使用 c 时它仍然显示为空
您应该在选项中添加value
属性:
<form action="first" > <!-- first servlet -->
<select name="loginAs">
<option value="Fan">Fan</option>
<option value="ClubMember">Club Member</option>
<option value="Admin">Admin</option>
</select>
</form>