首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

剩下最后一个有关问题未解决了,望前辈指点

2011-12-26 
剩下最后一个问题未解决了,望前辈指点a.jsp页面(从表tiku提取考试题目,都是选择题)%@pagecontentType t

剩下最后一个问题未解决了,望前辈指点
a.jsp   页面   (从表tiku提取考试题目,都是选择题)

<%@   page   contentType= "text/html;   charset=gb2312 "   language= "java "   import= "java.io.*,java.sql.* "   %>
<jsp:useBean   id= "connBean "   scope= "session "   class= "bean.ConnDB "/>
<jsp:useBean   id= "employ "   class= "bean.employ "   scope= "session "/>  
<%
ResultSet   rs=connBean.executeQuery( "select   *   from   tiku ");
%>
<html>    
    <body>
    <form   name= "form1 "   method= "post "   action= "b.jsp "   target= "_top ">
    <%
int   question_index=1;
int   tmp_questionid=0;
while(rs.next())   {
tmp_questionid=rs.getInt( "id ");
%>
<table   width= "75% "   border= "0 ">
<tr>  
            <td   width= "15% "   align= "left "   valign= "top "> 答案 </td>
            <td   width= "85% "> <%= " <font   color=blue> ( "   +   question_index   +   ") </font>   "   +   rs.getString( "question ")%> (单选题) </td>
        </tr>

<tr>
                    <td>   <input   type= "radio "   name= " <%=tmp_questionid%> "   value= "A "> A </td> <td> <%=rs.getString( "keya ")%> </td> </tr>
  <tr>
                    <td>   <input   type= "radio "   name= " <%=tmp_questionid%> "   value= "B "> B </td> <td> <%=rs.getString( "keyb ")%> </td> </tr>
<tr>
                    <td>   <input   type= "radio "   name= " <%=tmp_questionid%> "   value= "C "> C </td> <td> <%=rs.getString( "keyc ")%> </td> </tr>
<tr>
                    <td>   <input   type= "radio "   name= " <%=tmp_questionid%> "   value= "D "> D </td> <td> <%=rs.getString( "keyd ")%> </td> </tr>
   
            </table> <p> </p>
<%
question_index++;
}  
%>
<p   align= "center ">  
        <input   type= "hidden "   name= "totaltime "   value= "0 ">
        <input   type= "button "   name= "submita "   value= "提交答卷 "     onclick= "JavaScript:subit() ">
    </p>
</form>

怎么在b.jsp   页面实现总分数多少?
(写过,但是总是不行)

sql2000   数据库
表名:tiku  
字段:id,question,keya,keyb,keyc,keyd,answer

表名:score
字段:id,s_id,score



[解决办法]
接收到数据后先跟ANSWER判断,int i=0;如果对的话就i+分数。累计后得总分,这样不行么
[解决办法]
把student_ansewer[ansewer_index]和paper_ansewer[ansewer_index]都打印出来看对不对
[解决办法]
out.print( "[ "+student_ansewer[ansewer_index]+ "] ");
out.print( "--- ");
out.println( "[ "+paper_ansewer[ansewer_index]+ "] ");
你这样打印试试,我怀疑在数据库中取出的数据包含空格
比如 "A "
如果这样的话就要trim之后再比较

热点排行