1.直接往input中读取(form 的action用该servlet,servlet用request.getAttribute获得值) 

jsp:
<input type="text" name="title" >

servlet:
String title
=request.getAttribute("title");

 

 

 

 

2.带hidden的input

jsp:
<input type="hidden" name="title" value"title_value">

servlet:
String title
= request.getAttribute("title");

 

 

 

3.将checkbox的值传到servlet

代码
jsp:
<%
  
for(int i=1;i<N;i++) {
%>
<input type="checkbox" name="checkbox"+<%=%>   value=<%=%> />
<% i++; } %>

servlet:
String ini;
for (int i = 1; i < N; i++) {
    ini
=request.getParameter("checkbox"+i); 
  
if(ini!=null){                     //被选中的checkbox执行相关操作
    ......
    }

 

     

相关文章:

  • 2021-11-03
  • 2022-01-10
  • 2019-03-12
  • 2022-12-23
  • 2022-12-23
  • 2021-07-26
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-17
  • 2022-12-23
  • 2022-01-08
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案