一项作业,搞不出来,求教
做一个html和一个jsp,jsp接收html的数据并在jsp上打印。但我却总是打印出null。写出代码,求高手指出错误
resume.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>resume</title>
<style type="text/css">
#form1 p {
font-family: Times New Roman, Times, serif;
}
#form1 p {
font-family: 黑体;
}
#form1 p {
font-family: MS Serif, New York, serif;
}
</style>
</head>
<form action="resume.jsp" method="post" enctype="multipart/form-data" name="form1" id="form1" >
  <p>姓名
    <label for="textfield"></label>
  <input type="text" name="xingming" id="xingming" />
  </p>
  <p>密码
    <label for="textfield2"></label>
    <input type="password" name="mima" id="mima" />
  </p>
  <p>个人描述<br />
    <label for="textarea"></label>
    <textarea name="miaoshu" id="miaoshu" cols="45" rows="5"></textarea>
  </p>
  <p>性别
    <label>
      <input type="radio" name="xingbie" value="man" id="xingbie_0" />
      女</label>
    <input type="radio" name="xingbie" value="man" id="xingbie1_1" />
  男</p>
  <p>年级
    <label for="select"></label>
    <select name="nianji" id="nianji">
      <option selected="selected">one</option>
      <option>two</option>
      <option>three</option>
      <option>four</option>
    </select>
  </p>
  <p>爱好
    <label>
      <input type="checkbox" name="aihao" value="sport" id="aihao1_0" />
      运动</label>
    <label>
      <input type="checkbox" name="aihao" value="printing" id="aihao1_1" />
      绘画</label>
    <label>
      <input type="checkbox" name="aihao" value="music" id="aihao1_2" />
      音乐</label>
<br />
    <label> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <input type="checkbox" name="aihao1_3" value="dance" id="aihao1_3" />
    </label>
舞蹈
<label>
  <input type="checkbox" name="aihao1_4" value="meishu" id="aihao1_4" />
  美术</label>
<label>
  <input type="checkbox" name="aihao1_5" value="travel" id="aihao1_5" />
  旅游</label>
<br />
<br /> 
Resume
<label for="fileField"></label>
<input type="file" name="fileField" id="fileField" />
<br />
<br />
<input type="submit" name="button" id="button" value="确定" />
&nbsp;&nbsp;
     <input type="reset" name="button2" id="button2" value="重置" />
<br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
  </p>
</form>
</body>
</html>resume.jsp
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*"  errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>resume</title>
</head>
<body><%
String name=request.getParameter("xingming");
String mima = request.getParameter("mima");
String miaoshu = request.getParameter("miaoshu");
String xingbie = request.getParameter("xingbie");
String nianji = request.getParameter("nianji");
String aihao = request.getParameter("aihao");out.print("姓名:"+name);
out.print("<p>密码:"+ mima);
out.print("<p>人物描述:"+ miaoshu);
out.print("<p>性别:"+ xingbie);
out.print("<p>年级:"+ nianji);
out.print("<p>爱好:"+ aihao);
%></body>
</html>

解决方案 »

  1.   

    enctype="multipart/form-data"  这个删了看看
      

  2.   

    http://my.csdn.net/dawn_hu/album/detail/1151315
    这就是输出结果,请大家帮帮忙了
      

  3.   

    好像只看到</body>了,你是不是删掉<body>了,难道是我看错了!!
      

  4.   

    你需要一对<table></table>
    <form>
    <table></table>
    </form>其他都没有问题
      

  5.   

    把你的第一个FORM 放到BODY 下呢
      

  6.   

    把resume.html换成.jsp页面 再把enctype="multipart/form-data"删了。。
      

  7.   

    <form action="resume.jsp" method="post" enctype="multipart/form-data" name="form1" id="form1" >
    ==>
    <body>
    <form action="resume.jsp" method="post"  name="form1" id="form1" >
      

  8.   

    首先把 enctype="multipart/form-data" 删除然后把你提交按钮的名字和ID改掉  不能以关键字命名  button是关键字
      

  9.   

    首先把enctype="multipart/form-data"删了,它的意思是把提交数据作为二进制数据了!其次再检查一下你的路径,有可能是路径的问题