问题描述
//通过paperNo查询试题信息DAO.javapublicTopicqueryByPaperNo(IntegerpaperNo){StringHQL1="FROMTopicastwheret.paperNo=?";Sessionsession=HibernateSessionFactory.getSession();Topictop=null;Queryqtop=getSession().createQuery(HQL1);qtop.setParameter(0,paperNo);Listl=qtop.list();Iteratoriter=l.iterator();if(iter.hasNext()){top=(Topic)iter.next();}returntop;}action.java//查询条件publicStringexecuteD(){HttpServletRequestrequest=ServletActionContext.getRequest();ServletContextservletContext=ServletActionContext.getServletContext();request.getSession().setAttribute("paperNo",paperNo);System.out.println(paperNo);TopicDAOto=newTopicDAO();System.out.println("3233333333333");Topictop=null;top=to.queryByPaperNo(paperNo);if(top!=null){Map<String,Object>session=ActionContext.getContext().getSession();session.put("paperNo",paperNo);return"have";}return"never";}publicStringexecuteB(){System.out.println("54565565");TopicDAOt=newTopicDAO();HttpServletRequestrequest=ServletActionContext.getRequest();ServletContextservletContext=ServletActionContext.getServletContext();paperNo=(Integer)request.getSession().getAttribute("paperNo");System.out.println("paperNo"+paperNo);Topictop=t.queryByPaperNo(paperNo);request.getSession().setAttribute("top",top);System.out.println(top+"4444444444444");return"success";}结果就显示这么多第5套.(分)A.B.C.D.正确答案:删除首页上一页下一页末页第1/1页,每页显示3条,共1条跳转至页
解决方案
解决方案二:
你页面上怎么写的?
解决方案三:
<%@pagelanguage="java"import="java.util.*"pageEncoding="utf-8"contentType="text/html;charset=utf-8"%><%@tagliburi="http://java.sun.com/jsp/jstl/core"prefix="c"%><%@pageimport="com.system.page.*"%><%@pageimport="com.system.vo.*"%><jsp:useBeanid="topic"class="com.system.vo.Topic"scope="page"/><jsp:useBeanid="topicDAO"class="com.system.dao.TopicDAO"scope="page"/><jsp:useBeanid="topicAction"class="com.system.action.TopicAction"scope="page"/><%Stringpath=request.getContextPath();StringbasePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN"><html><head><basehref="<%=basePath%>"><title>维护试题</title><metahttp-equiv="pragma"content="no-cache"><metahttp-equiv="cache-control"content="no-cache"><metahttp-equiv="expires"content="0"><metahttp-equiv="keywords"content="keyword1,keyword2,keyword3"><metahttp-equiv="description"content="Thisismypage"><!--<linkrel="stylesheet"type="text/css"href="styles.css">--></head><%if(session.getAttribute("list")!=null){Listlist=(List)session.getAttribute("list");pageContext.setAttribute("list",list);session.removeAttribute("list");}else{Listlist=topicDAO.findHomePage();pageContext.setAttribute("list",list);}%><body><formaction=""method="post"><table><tr><td>第${top.paperNo}套</td></tr><tr><td>${top.topicNo}. ${top.topicContext}(${top.paperTopicScores}分)</td></tr><tr><td><%Topict=(Topic)session.getAttribute("top");System.out.println(t.getA()+"111111111111111");%>A. ${top.a}</td></tr><tr><td>B. ${top.b}</td></tr><tr><td>C. ${top.c}</td></tr><tr><td>D. ${top.d}</td></tr><tr><td>正确答案:${top.rightAnwer}</td><td><ahref="">修改</a></td><td><ahref="./struts/del?paperNo=${top.paperNo}&topicNo=${top.topicNo}">删除</a></td></tr></table></form><tablewidth="100%"><tr><%if(PageUtil.getIsHomePage()==false){%><tdalign="center"colspan="10"><ahref="./struts/homePage_page">首页</a><ahref="./struts/previouePage_page">上一页</a><%}else{%>首页上一页<%}%><%if(PageUtil.getIsLastPage()==false){%><ahref="./struts/nextPage_page">下一页</a><ahref="./struts/lastPage_page">末页</a><%}else{%>下一页末页<%}%>第<%=PageUtil.getIndexPage()%>/<%=PageUtil.getCountPage()%>页,每页显示<%=PageUtil.getPageCount()%>条,共<%=PageUtil.getAllCounts()%>条<formname="go"method="post"action="./struts/go_page">跳转至<inputtype="text"name="pageGo"size="4"maxlength="4"/>页<inputtype="submit"value="GO"/></form></td></tr></table>
解决方案四:
我吧action里改成了这样,那位会的,帮我看看,急用,一万分的感谢//查询条件publicStringexecuteD(){HttpServletRequestrequest=ServletActionContext.getRequest();TopicDAOto=newTopicDAO();System.out.println("paperNo"+paperNo);Topictop=to.queryByPaperNo(paperNo);if(top!=null){//Map<String,Object>session=ActionContext.getContext().getSession();//session.put("top",top);request.getSession().setAttribute("top",top);System.out.println("查询成功");System.out.println(top.getA());return"have";}return"never";}