//通过paperNo查询试题信息 DAO.java
public Topic queryByPaperNo(Integer paperNo){
String HQL1="FROM Topic as t where t.paperNo = ?";
Session session = HibernateSessionFactory.getSession();
Topic top = null;
Query qtop=getSession().createQuery(HQL1);
qtop.setParameter(0, paperNo);
List l=qtop.list();
Iterator iter=l.iterator();
if(iter.hasNext()){
top=(Topic) iter.next();
}
return top;
}
action.java
//查询条件
public String executeD(){
HttpServletRequest request = ServletActionContext.getRequest();
ServletContext servletContext = ServletActionContext.getServletContext();
request.getSession().setAttribute("paperNo", paperNo);
System.out.println(paperNo);
TopicDAO to=new TopicDAO();
System.out.println("3233333333333");
Topic top = null;
top=to.queryByPaperNo(paperNo);
if(top!=null){
Map<String, Object> session = ActionContext.getContext().getSession();
session.put("paperNo", paperNo);
return "have";
}
return "never";
}
public String executeB(){
System.out.println("54565565");
TopicDAO t=new TopicDAO();
HttpServletRequest request = ServletActionContext.getRequest();
ServletContext servletContext = ServletActionContext.getServletContext();
paperNo = (Integer) request.getSession().getAttribute("paperNo");
System.out.println("paperNo"+paperNo);
Topic top=t.queryByPaperNo(paperNo);
request.getSession().setAttribute("top", top);
System.out.println(top+"4444444444444");
return "success";
}
结果就显示这么多第5套
. (分)
A.
B.
C.
D.
正确答案: 删除 首页上一页 下一页末页 第1/1页, 每页显示3条, 共1条
跳转至 页
public Topic queryByPaperNo(Integer paperNo){
String HQL1="FROM Topic as t where t.paperNo = ?";
Session session = HibernateSessionFactory.getSession();
Topic top = null;
Query qtop=getSession().createQuery(HQL1);
qtop.setParameter(0, paperNo);
List l=qtop.list();
Iterator iter=l.iterator();
if(iter.hasNext()){
top=(Topic) iter.next();
}
return top;
}
action.java
//查询条件
public String executeD(){
HttpServletRequest request = ServletActionContext.getRequest();
ServletContext servletContext = ServletActionContext.getServletContext();
request.getSession().setAttribute("paperNo", paperNo);
System.out.println(paperNo);
TopicDAO to=new TopicDAO();
System.out.println("3233333333333");
Topic top = null;
top=to.queryByPaperNo(paperNo);
if(top!=null){
Map<String, Object> session = ActionContext.getContext().getSession();
session.put("paperNo", paperNo);
return "have";
}
return "never";
}
public String executeB(){
System.out.println("54565565");
TopicDAO t=new TopicDAO();
HttpServletRequest request = ServletActionContext.getRequest();
ServletContext servletContext = ServletActionContext.getServletContext();
paperNo = (Integer) request.getSession().getAttribute("paperNo");
System.out.println("paperNo"+paperNo);
Topic top=t.queryByPaperNo(paperNo);
request.getSession().setAttribute("top", top);
System.out.println(top+"4444444444444");
return "success";
}
结果就显示这么多第5套
. (分)
A.
B.
C.
D.
正确答案: 删除 首页上一页 下一页末页 第1/1页, 每页显示3条, 共1条
跳转至 页
解决方案 »
- flex+java web工程移植到另一电脑,路径问题?
- JSP中动态生成HTML文件?
- 我HTML里有多个<div class="scroll" id="scroll"> JS能动态吗?
- 求将数组中的数据插入到ORACLE数据库中效率高的方法!
- 急急急!统计在文本框中输入的字符数的问题?
- [请教]ResultSet is not updateable(单表查询返回结果集可以更新,但多表查询返回结果集就不能更新)
- Struts 2.0 validation验证,错误返回一个Action,但Error信息不能显示,请高手帮忙!!
- 急!各位高手帮忙看看这个JAVA小程序该怎么写?
- 请问如何从request或response中得到当前页面的前一个页面地址?
- 在wsad5中Servlet路径问题
- 求助 关于http status 500的,谢谢
- jsp的标签的路径设置
contentType="text/html; charset=utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page import="com.system.page.*"%>
<%@ page import="com.system.vo.*"%>
<jsp:useBean id="topic" class="com.system.vo.Topic" scope="page" />
<jsp:useBean id="topicDAO" class="com.system.dao.TopicDAO" scope="page" />
<jsp:useBean id="topicAction" class="com.system.action.TopicAction"
scope="page" /><%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>"> <title>维护试题</title> <meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
--> </head> <%
if (session.getAttribute("list") != null) {
List list = (List) session.getAttribute("list");
pageContext.setAttribute("list", list);
session.removeAttribute("list");
} else {
List list = topicDAO.findHomePage();
pageContext.setAttribute("list", list); }
%> <body>
<form action="" method="post">
<table>
<tr>
<td>
第${top.paperNo}套
</td>
</tr>
<tr>
<td>
${top.topicNo}. ${top.topicContext}(${top.paperTopicScores}分)
</td>
</tr>
<tr>
<td>
<%Topic t=(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>
<a href="">修改</a>
</td>
<td>
<a
href="./struts/del?paperNo=${top.paperNo}&topicNo=${top.topicNo}">
删除 </a>
</td>
</tr>
</table> </form>
<table width="100%">
<tr>
<%
if (PageUtil.getIsHomePage() == false) {
%>
<td align="center" colspan="10">
<a href="./struts/homePage_page">首页</a>
<a href="./struts/previouePage_page">上一页</a>
<%
} else {
%>
首页上一页
<%
}
%>
<%
if (PageUtil.getIsLastPage() == false) {
%>
<a href="./struts/nextPage_page">下一页</a>
<a href="./struts/lastPage_page">末页</a>
<%
} else {
%>
下一页末页
<%
}
%> 第<%=PageUtil.getIndexPage()%>/<%=PageUtil.getCountPage()%>页, 每页显示<%=PageUtil.getPageCount()%>条,
共<%=PageUtil.getAllCounts()%>条 <form name="go" method="post" action="./struts/go_page">
跳转至
<input type="text" name="pageGo" size="4" maxlength="4" />
页
<input type="submit" value="GO" />
</form>
</td>
</tr>
</table>
public String executeD(){
HttpServletRequest request = ServletActionContext.getRequest();
TopicDAO to=new TopicDAO();
System.out.println("paperNo"+paperNo);
Topic top = 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";
}