我要将一个表单里面的复选框内容传到另一个页面里面,请问如何做 10
以下是servlet类的内容:importjava.io.*;importjavax.servlet.*;importjavax.servlet.http.*;publi...
以下是servlet类的内容:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class MyEnrol extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException{
response.setContentType("text/html;charset=GBK");
PrintWriter pw=response.getWriter();
pw.println("<html>");
pw.println("<head><title>Enrol</title></head>");
pw.println("<body>");
String Check[] = request.getParameterValues("txtcheckbox");
for(int i=0;Check!=null&&i<Check.length;i++){
String Checkb = Check[i];
byte[] d = Checkb.getBytes("ISO-8859-1");
String CheckBox = new String(d,"GBK");
pw.println("<table border=0 align=center width=50%>");
pw.println("<tr><td colspan=2><center><font color=red size=6>用户注册详细信息</font></center></td></tr>");
pw.println("<tr><td>爱 好:</td><td><font color=red Face=宋体>"+CheckBox+"</font></td></tr>");
pw.println("</table></body></html>");
pw.close();
}
}
protected void doPost(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException{
doGet(request,response);
}
public void destroy(){
super.destroy();
}
}
以下是JSP里面的内容
<tr><td><span><strong>爱 好:</strong></span></td>
<td><input name="txtcheckbox" type="checkbox" value="唱歌">唱歌
<input name="txtcheckbox" type="checkbox" value="看书">看书
<input name="txtcheckbox" type="checkbox" value="玩电脑">玩电脑
<input name="txtcheckbox" type="checkbox" value="体育">体育</td>
</tr>
如何将jsp中复选框的内容用post方法传到servlet类中去,也就是在另一个页面中显示结果?急求各位大侠帮助解决。谢谢 展开
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class MyEnrol extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException{
response.setContentType("text/html;charset=GBK");
PrintWriter pw=response.getWriter();
pw.println("<html>");
pw.println("<head><title>Enrol</title></head>");
pw.println("<body>");
String Check[] = request.getParameterValues("txtcheckbox");
for(int i=0;Check!=null&&i<Check.length;i++){
String Checkb = Check[i];
byte[] d = Checkb.getBytes("ISO-8859-1");
String CheckBox = new String(d,"GBK");
pw.println("<table border=0 align=center width=50%>");
pw.println("<tr><td colspan=2><center><font color=red size=6>用户注册详细信息</font></center></td></tr>");
pw.println("<tr><td>爱 好:</td><td><font color=red Face=宋体>"+CheckBox+"</font></td></tr>");
pw.println("</table></body></html>");
pw.close();
}
}
protected void doPost(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException{
doGet(request,response);
}
public void destroy(){
super.destroy();
}
}
以下是JSP里面的内容
<tr><td><span><strong>爱 好:</strong></span></td>
<td><input name="txtcheckbox" type="checkbox" value="唱歌">唱歌
<input name="txtcheckbox" type="checkbox" value="看书">看书
<input name="txtcheckbox" type="checkbox" value="玩电脑">玩电脑
<input name="txtcheckbox" type="checkbox" value="体育">体育</td>
</tr>
如何将jsp中复选框的内容用post方法传到servlet类中去,也就是在另一个页面中显示结果?急求各位大侠帮助解决。谢谢 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询