在线急等,JSP网页表单提交后为什么得不到表单中的数据
JSP网页表单提交后为什么得不到表单中的数据,提交后下页的几个赋值语句
if(request.getParameter("text")!=null)
question.questionText =request.getParameter("text");
if(request.getParameter("xuanX1")!=null)
question.questionText =question.questionText+"A"+request.getParameter("xuanX1");
if(request.getParameter("xuanX2")!=null)
question.questionText =question.questionText+"B"+request.getParameter("xuanX2");
if(request.getParameter("xuanX3")!=null)
question.questionText =question.questionText+"C"+request.getParameter("xuanX3");
if(request.getParameter("xuanX4")!=null)
question.questionText =question.questionText+"D"+request.getParameter("xuanX4");
if(request.getParameter("questionType")!=null)
question.questionTypeNo =new String(request.getParameter("questionType").getBytes("ISO-8859-1"),"gb2312");
if(request.getParameter("answer")!=null)
question.questionAnswer =new String(request.getParameter("answer").getBytes("ISO-8859-1"),"gb2312");
通过tomcat看这几个变量最后都是空值,这是为什么啊,我觉得是表单写的不对
<%@ page contentType="text/html; charset=gb2312" language="java"%>
<%@ page import="java.sql.*,com.object.*,com.database.*" %>
<jsp:useBean scope="page" id="question" class="com.object.Question" />
<jsp:useBean scope="page" id="point" class="com.object.Point" />
<jsp:useBean scope="page" id="executeWay" class="com.database.ExecuteWay" />
<html>
<head>
<title>在线考试――教师功能</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<SCRIPT language=javascript>
<!--
function display(id){
var traget=document.getElementById(id);
if(traget.style.display=="none" ){
traget.style.display="";
}else{
traget.style.display="none";
}
}
//-->
</SCRIPT>
</head>
<body>
<div align="center">
<TABLE cellSpacing=1 cellPadding=3 width="90%" align=center border=0>
<FORM name="form1" onReset="return confirm('确定要清空当前表单吗?');"
onsubmit="return infocheck();" action=addQuestionSave.jsp method=post enctype="multipart/form-data" >
<TBODY>
<TR bgColor=#ffffff>
<TD align=right width="17%">科 目:</TD>
<TD align=left width="83%">
<%
String ssql="select distinct subject from point";
ResultSet srs = null;
srs = executeWay.exeSqlQuery(ssql);
if(srs.next()){
%>
<select name="subject" id="subject">
<option value="<%=srs.getString(1) %>" selected><%=srs.getString(1) %></option>
<% }
while(srs.next())
{ %>
<option value="<%=srs.getString(1) %>"><%=srs.getString(1) %></option>
<%} %>
</select></TD>
</TR>
<TR bgColor=#ffffff>
<TD align=right>题 型:</TD>
<TD align=left>
<%
String tsql="select * from questionType";
ResultSet trs = null;
trs =executeWay.exeSqlQuery(tsql);
if(trs==null);
if(trs.next()){
%>
<select name="questionType" id="questionType" onChange="display('xuanX')">
<option value="<%=trs.getString("questionTypeNo") %>" selected><%=trs.getString("questionType") %></option>
<% }
while(trs.next())
{ %>
<option value="<%=trs.getString("questionTypeNo") %>"><%=trs.getString("questionType") %></option>
<%} %>
</select>
</TD></TR>
<TR bgColor=#ffffff>
<TD vAlign=top align=right>知 识 点:</TD>
<TD align=left><%
ResultSet prs=null;
if(request.getParameter("subject")!=null){
prs=point.showBySubject(request.getParameter("subject"));}
else prs=point.showBySubject("java");
while(prs.next()){
%>
<label>
<input type="checkbox" name="point" value="<%=prs.getString("pointID") %>">
<%=prs.getString("pointName") %></label>
<%} %></TD>
</TR>
<TR bgColor=#ffffff>
<TD vAlign=top align=right>题 目:</TD>
<TD align=left><textarea name=text rows=6 id="text" style="WIDTH: 233px"></textarea></TD>
</TR>
<TR id="xuanX" bgColor=#ffffff>
<TD vAlign=top align=right>选 项:</TD>
<TD align=left><p>
A
<INPUT name=xuanX1 maxLength=15>
</p>
<p>
B
<INPUT name=xuanX2 maxLength=15>
</p>
<p>
C
<INPUT name=xuanX3 maxLength=15>
</p>
<p>
D
<INPUT name=xuanX4 maxLength=15>
</p></TD>
</TR>
<TR id=answers bgColor=#ffffff>
<TD vAlign=top align=right>答 案:</TD>
<TD align=left><textarea name=answer rows=6 id="answer" style="WIDTH: 233px"></textarea>
(多项答案请以“$”分隔)</TD>
</TR>
<TR>
<TD colSpan=2>
<INPUT type=submit value="保 存" name=submit> <INPUT type=reset value="重 填" name=reset> <INPUT type=button value="关 闭" onclick="window.close();">
</TD></TR>
</FORM></TABLE>
</div>
</body>
</html>
[解决办法]
看看infocheck里面是什么内容,其它表单控件如subject有值提交上去吗
那些为空的表单控件,真的有填写内容吗
[解决办法]
保存在session里调用
jsp提交第一个表单的参数保存在session里,然后你提交第二个表单的时候就可以获取第一个session里的参数,先设置,再取值
session.setAttribute("text",text);
session.getAttribute("text");