jsp和servlet之间传值

jsp通过form表单提交数据

<form name="login" method="post" action="project/servlet-name"> <input type="text" name="Pname"> <input type="password" name="pwd"> <input type="submit" value="提交"> </form>

 

servlet接收数据

servlet_name extends HttpServlet(HttpServletRequest request,HttpServletResponse response)

 

doGet{

String name,pwd;

name=request.getParameter("Pname");

pwd=request.getParameter("pwd");

 

}

 

doPost{

doGet(request,response);

 

}

 

 

 

当一个组件可能传递多个值时,用getParameterValues接受

<select name="Favor">

<option>

<option>
<select>

 

String[] favor=request.getParameterValues("Favor");

 

 

 

 

 

 

 

你可能感兴趣的:(jsp和servlet之间传值)