dao:
package org.junshi.dao;import java.util.List;public interface ScspRealtimeEventDAO {
// 计算出总记录数
public int getAllCount()throws Exception;
// 查询出所有的数据
public List queryAllUser(int currentPage, int lineSize)throws Exception;
}
impledao:
package org.junshi.daoImpl;import java.util.List;import org.hibernate.Query;
import org.junshi.dao.ScspRealtimeEventDAO;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;public class ScspRealtimeEventImpl extends HibernateDaoSupport implements
ScspRealtimeEventDAO { public int getAllCount() throws Exception {
int count=0;
String hql="SELECT COUNT(id.eventId) FROM ScspRealtimeEvents";
Query q=super.getSession().createQuery(hql);
count=(Integer)q.list().get(0);
return count;
} public List queryAllUser(int currentPage, int lineSize) throws Exception {
String hql="FROM ScspRealtimeEvents";
List all=null;
Query q=super.getSession().createQuery(hql);
q.setFirstResult((currentPage-1)*lineSize);
q.setMaxResults(lineSize);
all=q.list();
return all;
}}
package org.junshi.dao;import java.util.List;public interface ScspRealtimeEventDAO {
// 计算出总记录数
public int getAllCount()throws Exception;
// 查询出所有的数据
public List queryAllUser(int currentPage, int lineSize)throws Exception;
}
impledao:
package org.junshi.daoImpl;import java.util.List;import org.hibernate.Query;
import org.junshi.dao.ScspRealtimeEventDAO;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;public class ScspRealtimeEventImpl extends HibernateDaoSupport implements
ScspRealtimeEventDAO { public int getAllCount() throws Exception {
int count=0;
String hql="SELECT COUNT(id.eventId) FROM ScspRealtimeEvents";
Query q=super.getSession().createQuery(hql);
count=(Integer)q.list().get(0);
return count;
} public List queryAllUser(int currentPage, int lineSize) throws Exception {
String hql="FROM ScspRealtimeEvents";
List all=null;
Query q=super.getSession().createQuery(hql);
q.setFirstResult((currentPage-1)*lineSize);
q.setMaxResults(lineSize);
all=q.list();
return all;
}}
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package org.junshi.struts.action;import java.util.List;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import org.junshi.dao.ScspRealtimeEventDAO;
import org.junshi.struts.form.ScspRealtimeEventForm;/**
* MyEclipse Struts
* Creation date: 06-16-2008
*
* XDoclet definition:
* @struts.action path="/scspRealtimeEvent" name="scspRealtimeEventForm" input="/form/scspRealtimeEvent.jsp" scope="request" validate="true"
*/
public class ScspRealtimeEventAction extends DispatchAction {
/*
* Generated Methods
*/ /**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
private ScspRealtimeEventDAO scspRealtimeEventdao;
public ScspRealtimeEventDAO getScspRealtimeEventdao() {
return scspRealtimeEventdao;
}
public void setScspRealtimeEventdao(ScspRealtimeEventDAO scspRealtimeEventdao) {
this.scspRealtimeEventdao = scspRealtimeEventdao;
}
public ActionForward queryAll(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
ScspRealtimeEventForm scspRealtimeEventForm = (ScspRealtimeEventForm) form;// TODO Auto-generated method stub
List all = null;
int currentPage = 1;
int lineSize = 5;
int allRecorders = 0;
try {
currentPage = Integer.parseInt(request.getParameter("cp"));
} catch (Exception e) { }
try {
allRecorders=this.scspRealtimeEventdao.getAllCount();
all = this.scspRealtimeEventdao.queryAllUser(currentPage, lineSize);
} catch (Exception e) {
e.printStackTrace();
}
request.setAttribute("currentPage", currentPage);
request.setAttribute("lineSize", lineSize);
request.setAttribute("allRecorders", allRecorders);
request.setAttribute("all", all);
System.out.println(allRecorders);
request.setAttribute("jspUrl", "scspRealtimeEvent.do");
request.setAttribute("status", "queryAll");
return mapping.findForward("showit");
}
}jsp:
<%@ page language="java" pageEncoding="UTF-8"%><%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html lang="true">
<head>
<html:base />
<title>showit.jsp</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>
<body>
<center>
<br>
<logic:present name="all" scope="request">
<jsp:include flush="true" page="split_page.jsp">
<jsp:param name="jspUrl" value="${jspUrl}" />
<jsp:param name="lineSize" value="${lineSize}" />
<jsp:param name="allRecorders" value="${allRecorders}" />
<jsp:param name="keyWords"
value="<%=request.getParameter("keyWords")%>" />
<jsp:param name="currentPage" value="${currentPage}" />
<jsp:param name="status" value="${status}" />
<jsp:param name="searchFlag" value="F" />
</jsp:include>
<table border="1" width="100%">
<tr style="background-color: #CCFFFF">
<td style="color:#FF6600;">
列号
<br>
</td>
<td style="color:#FF6600;">
用户名
<br>
</td>
<td style="color:#FF6600;">
密码
<br>
</td>
</tr>
<%
int i=0;
%>
<logic:iterate id="admin" name="all" scope="request">
<tr width="1" heigth="5">
<td>
<%=i+1%>
<%i=i+1; %>
<br>
</td>
<td >
${admin.id.eventId}
<br>
</td>
<td >
${admin.id.eventDt}
<br>
</td>
</tr>
</logic:iterate>
</table>
</logic:present>
</center>
</body>
</html:html>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
<class name="org.junshi.vo.ScspRealtimeEvents" table="SCSP_REALTIME_EVENTS">
<composite-id name="id" class="org.junshi.vo.ScspRealtimeEventsId">
<key-property name="eventId" type="java.lang.Long">
<column name="EVENT_ID" />
</key-property>
<key-property name="eventDt" type="java.util.Date">
<column name="EVENT_DT" length="23" />
</key-property>
<key-property name="eventType" type="java.lang.String">
<column name="EVENT_TYPE" length="4" />
</key-property>
<key-property name="eventTypeD" type="java.lang.String">
<column name="EVENT_TYPE_D" length="32" />
</key-property>
<key-property name="assetRid" type="java.lang.Integer">
<column name="ASSET_RID" />
</key-property>
<key-property name="eventSeq" type="java.lang.Integer">
<column name="EVENT_SEQ" />
<key-property name="agentVersion" type="java.lang.String">
<column name="AGENT_VERSION" length="16" />
</key-property>
<key-property name="ntLogSource" type="java.lang.String">
<column name="NtLog_Source" length="2048" />
</key-property>
<key-property name="ntLogEventLog" type="java.lang.String">
<column name="NtLog_EventLog" length="128" />
</key-property>
<key-property name="ntLogEventType" type="java.lang.String">
<column name="NtLog_EventType" length="14" />
</key-property>
<key-property name="ntLogEventId" type="java.lang.String">
<column name="NtLog_EventID" length="512" />
</key-property>
<key-property name="ntLogCategory" type="java.lang.String">
<column name="NtLog_Category" length="128" />
</key-property>
<key-property name="ntLogComputerName" type="java.lang.String">
<column name="NtLog_ComputerName" length="128" />
</key-property>
<key-property name="sysLogFacility" type="java.lang.String">
<column name="SysLog_Facility" length="2048" />
</key-property>
<key-property name="prevModulePath" type="java.lang.String">
<column name="Prev_ModulePath" length="128" />
</key-property>
<key-property name="prevThreadId" type="java.lang.String">
<column name="Prev_ThreadID" length="128" />
</key-property>
<key-property name="prevOsresult" type="java.lang.String">
<column name="Prev_OSResult" length="128" />
</key-property>
<key-property name="prevCspresult" type="java.lang.String">
<column name="Prev_CSPResult" length="128" />
</key-property>
<key-property name="prevRequested" type="java.lang.String">
<column name="Prev_Requested" length="256" />
</key-property>
<key-property name="prevRequestedRw" type="java.lang.String">
<column name="Prev_RequestedRW" length="5" />
</key-property>
<key-property name="prevNtcreateOpt" type="java.lang.String">
<column name="Prev_NTCreateOpt" length="128" />
</key-property>
<key-property name="prevFileFilePath" type="java.lang.String">
<column name="PrevFile_FilePath" length="2048" />
</key-property>
<key-property name="prevRegRegPath" type="java.lang.String">
<column name="PrevReg_RegPath" length="2048" />
</key-property>
<key-property name="prevMemMechanism" type="java.lang.String">
<column name="PrevMem_Mechanism" length="128" />
</key-property>
<key-property name="prevMemInjecteeProcessName" type="java.lang.String">
<column name="PrevMem_InjecteeProcessName" length="128" />
</key-property>
<key-property name="prevMemInjecteeProcessId" type="java.lang.String">
<column name="PrevMem_InjecteeProcessID" length="128" />
</key-property>
<key-property name="prevMemInjecteeThreadId" type="java.lang.String">
<column name="PrevMem_InjecteeThreadID" length="128" />
</key-property>
<key-property name="prevNetProtocol" type="java.lang.String">
<column name="PrevNet_Protocol" length="2048" />
</key-property>
<key-property name="prevNetLocalPort" type="java.lang.String">
<column name="PrevNet_LocalPort" length="128" />
</key-property>
<key-property name="prevNetLocalIp" type="java.lang.String">
<column name="PrevNet_LocalIP" length="128" />
</key-property>
<key-property name="prevNetRemoteIp" type="java.lang.String">
<column name="PrevNet_RemoteIP" length="128" />
</key-property>
<key-property name="prevNetRemotePort" type="java.lang.String">
<column name="PrevNet_RemotePort" length="128" />
</key-property>
<key-property name="prevNetPortService" type="java.lang.String">
<column name="PrevNet_PortService" length="128" />
</key-property>
<key-property name="prevNetPortServiceDescr" type="java.lang.String">
<column name="PrevNet_PortServiceDescr" length="128" />
</key-property>
<key-property name="prevOscallResource" type="java.lang.String">
<column name="PrevOSCall_Resource" length="2048" />
</key-property>
<key-property name="value4" type="java.lang.String">
<column name="VALUE4" length="128" />
</key-property>
</composite-id>
</class>
</hibernate-mapping>
${admin.id.eventId}
${admin.id.eventDt}
把上面,两个换为1,2是可以出来的!
说明的我all值不是空的!
不知道为什么?难道我的
${admin.id.eventId}
${admin.id.eventDt} 写错了???
<% if (index % 2 == 0) { %>
<tr bgcolor="#e2f3fa" height="20" onMouseOut="mout(this,'#e2f3fa');" onMouseOver="mover(this,'#aedefd');">
<% } else { %>
<tr bgcolor="#ffffff" height="20" onMouseOut="mout(this,'#ffffff');" onMouseOver="mover(this,'#aedefd');">
<% } %>
<td ><bean:write name="GList" property="id.goodsId" /></td>
<td ><bean:write name="GList" property="id.goodsName" /></td>
<td ><bean:write name="GList" property="id.norms" /></td>
<td ><bean:write name="GList" property="id.producingArea" /></td>
<td ><bean:write name="GList" property="id.buyPrice" /></td>
<td ><bean:write name="GList" property="id.measureName" /></td>
<td ><bean:write name="GList" property="id.minStock" /></td>
<td ><bean:write name="GList" property="id.maxStock" /></td>
<td ><bean:write name="GList" property="id.re" /></td>
<td ></td>
<td></td>
</tr>
</logic:iterate>