怎样将问卷题目提交到数据库中
我在做一个在线问卷调查系统,已经构造了提交用户做好问卷题目框架,老师说userID要用session提取,可是用myeclipse和tomcat运行时,显示null。下面...
我在做一个在线问卷调查系统,已经构造了提交用户做好问卷题目框架,老师说userID要用session提取,可是用my eclipse和tomcat运行时,显示null。下面是具体的AnwserServlet的具体代码,求大神解答
// 获取每一个题目的对应的信息:userID,testID,questionID,answer
String strid=request.getSession().toString();
int userID =Integer.parseInt(strid);
int testID = Integer.parseInt(request.getParameter("testID"));
TestOpr to = new TestOpr();
Test t = to.getTestById(testID);
ArrayList<TestDetail> tlist = t.getDetailList();
for (TestDetail td : tlist) {
int questionID = td.getQuestionID();
String answer = request.getParameter("questionAnswer"+ td.getQuestionID());
Answer a = new Answer();
a.setUesrID(userID);
a.setTestID(testID);
a.setQuestionID(questionID);
a.setAnswer(answer);
AnswerOpr ao = new AnswerOpr();
ao.add(a); 展开
// 获取每一个题目的对应的信息:userID,testID,questionID,answer
String strid=request.getSession().toString();
int userID =Integer.parseInt(strid);
int testID = Integer.parseInt(request.getParameter("testID"));
TestOpr to = new TestOpr();
Test t = to.getTestById(testID);
ArrayList<TestDetail> tlist = t.getDetailList();
for (TestDetail td : tlist) {
int questionID = td.getQuestionID();
String answer = request.getParameter("questionAnswer"+ td.getQuestionID());
Answer a = new Answer();
a.setUesrID(userID);
a.setTestID(testID);
a.setQuestionID(questionID);
a.setAnswer(answer);
AnswerOpr ao = new AnswerOpr();
ao.add(a); 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询