关于jsp接收html数据的问题

DeanHu 2012-05-16 03:32:14
一项作业,搞不出来,求教
做一个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>         
<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="确定" />
  
<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>
...全文
226 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
首先把enctype="multipart/form-data"删了,它的意思是把提交数据作为二进制数据了!其次再检查一下你的路径,有可能是路径的问题
a312983516 2012-05-17
  • 打赏
  • 举报
回复
首先把 enctype="multipart/form-data" 删除

然后把你提交按钮的名字和ID改掉 不能以关键字命名 button是关键字
古布 2012-05-17
  • 打赏
  • 举报
回复
<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" >
ABCDEF 2012-05-17
  • 打赏
  • 举报
回复
把resume.html换成.jsp页面 再把enctype="multipart/form-data"删了。。
fanyuanwaifdl 2012-05-17
  • 打赏
  • 举报
回复
有可以根据标签取到数据的~
qifeifei 2012-05-16
  • 打赏
  • 举报
回复
这种表单有别的取值方式,你去搜索一下就有了
lyf520llp 2012-05-16
  • 打赏
  • 举报
回复
把你的第一个FORM 放到BODY 下呢
liujie616 2012-05-16
  • 打赏
  • 举报
回复
代码是没有问题的。是不是你的部署有问题?
盼盼love朵朵 2012-05-16
  • 打赏
  • 举报
回复
你需要一对<table></table>
<form>
<table>

</table>
</form>

其他都没有问题

Burn 2012-05-16
  • 打赏
  • 举报
回复
好像只看到</body>了,你是不是删掉<body>了,难道是我看错了!!
DeanHu 2012-05-16
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 的回复:]

不对,这种表单有别的取值方式,你去搜索一下就有了
[/Quote]

就是搜不到才来问的,
我应该搜什么才能找到啊
DeanHu 2012-05-16
  • 打赏
  • 举报
回复
http://my.csdn.net/dawn_hu/album/detail/1151315
这就是输出结果,请大家帮帮忙了
lisen_123a 2012-05-16
  • 打赏
  • 举报
回复
不对,这种表单有别的取值方式,你去搜索一下就有了
DeanHu 2012-05-16
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]

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

还是不行啊
lisen_123a 2012-05-16
  • 打赏
  • 举报
回复
enctype="multipart/form-data" 这个删了看看

81,090

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧