iframe里的页面跳转不行?

hooligan00011 hooligan00011 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
在做简单的考试系统时碰到的问题:
我在会话里存入生成的考试题目,按“下一题”显示一道题目
JSP里用btclick事件用jquery:

$("#btNext").click(function(){
answer = $("input[name='answerId']:checked").val();
pos = $("input[name='pos']").val();
utid = $("input[name='utid']").val();
alert("pos: "+pos+" utid: "+utid);
if(null == answer || "undefined" == answer){
alert("请选择题目,不能为空!");
return ;
}else{
$.ajax({
type: 'POST',
url: 'updateUT.do',
data: {'pos':Number(pos+1),'act':'next','utid':utid,'answer':answer}
});
}
});


springACTION里:

public ModelAndView updateUT(HttpServletRequest request,
HttpServletResponse response) throws Exception {
//上一题,下一题,完成
String act = (request.getParameter("act")==null)?"next":request.getParameter("act");
String utid = request.getParameter("utid");
int pos = (request.getParameter("pos")==null)?0:Integer.parseInt(request.getParameter("pos")); //位置
String answer = (request.getParameter("answer")==null)?" ":(String)(request.getParameter("answer"));
System.out.println("------------------"+utid+" ****** "+pos+" "+answer);

//下一题
if(act.equals("next")){
//保存答案

//显示下一题
List qs = (request.getSession().getAttribute("qs")==null)?null:(List)request.getSession().getAttribute("qs"); //qL是题目集
if(qs.size()>0){
pos = (pos >= (qs.size()-1))?qs.size():pos;
request.getSession().setAttribute("question", qs.get(pos));
}
request.getSession().setAttribute("pos", pos);
return new ModelAndView("student/test");
}else if(act.equals("pre")){ //上一题

}

return null;

return new ModelAndView("student/test");跳转到student/test.jsp没反应
我单步执行,question的值是对的,就是显示不出来。

jsp里:

<form name="form1">
<table align="center" cellspacing='0' cellpadding='0' border="1" style="font-size: 14px;border: 1px solid #ccc;width:100%;">

<tr>
<td>题目名称:${sessionScope.question.subject}</td>
</tr>
<tr>
<td><input type="radio" name="answerId" value="A"/>选项A:${sessionScope.question.option1}</td>
</tr>
<tr>
<td><input type="radio" name="answerId" value="B"/>选项B:${sessionScope.question.option2}</td>
</tr>
<tr>
<td><input type="radio" name="answerId" value="C"/>选项C:${sessionScope.question.option3}</td>
</tr>
<tr>
<td><input type="radio" name="answerId" value="D"/>选项D:${sessionScope.question.option4}</td>
</tr>


<tr><td>
<input type="hidden" name="utid" id="utid" value="${sessionScope.question.id}"/>
<input type="hidden" name="pos" id="pos" value="${sessionScope.pos}"/>
<input type="button" name="btPre" id="btPre" value="<" style="width:50px;height:25px;"/>
<input type="button" name="btNext" id="btNext" value=">" style="width:50px;height:25px;"/>
<input type="button" name="btOk" id="btOk" value="完成" style="width:50px;height:25px;"/>
</td></tr>
</table>
</form>

还有就是JSP放在iframe里。
...全文

相关推荐

评论 2
收藏 已收藏
分享
返回顶部
hooligan00011
Web 开发 81,108 成员 341,721 内容