首页上一页 1 下一页尾页 3 条记录 1/1页
急问《JSP项目开发全程实录》第六章办公自动化管理系统?
发表在JavaWeb图书答疑
2009-02-17
是否精华
是
否
版块置顶:
是
否
设置时间:
非永久
永久
起始时间:
结束时间:
是否扣分:
是
否
HTTP Status 400 - Invalid path /QuoteManage/findQuoteAction was requested
--------------------------------------------------------------------------------
type Status report
message Invalid path /QuoteManage/findQuoteAction was requested
description The request sent by the client was syntactically incorrect (Invalid path /QuoteManage/findQuoteAction was requested).
出错信息如上面:
前台页面中加入<form action="findQuoteAction.do?method=finQuote" method="post" name="form1">
struts-config.xml中加入代码
<form-beans>
<form-bean name="quoteForm" type="com.struts.form.QuoteForm">
</form-beans>
<action-mapping>
<action path="/findQuoteAction" name="quoteForm" scope="request" parameter="method" type="com.struts.action.FindQuoteAction"/>
</action-mappings>
请问为什么会出错,按照findQuoteAction.do写法应该已被servlet截获响应,但是为什么会到/QuoteManage/findQuoteAction找,应该是到com.struts.action下面找FindQuoteAction.java才对。
精彩评论 3
2009-02-19
板凳
已按照JJ要求修改,重启TM后,进入unsuccess.jsp页面;
先把偶的代码全帖出来,请JJ帮忙看看:
1、ActionForm:com.struts.Form/QuoteForm.java
**********************************************************************************
package com.struts.form;
import java.sql.Date;
import org.apache.struts.action.ActionForm;
public class QuoteForm extends ActionForm {
private String Itemnmbr;
private String Vendorid;
private String Itemdesc;
private String H;
private String W;
private String D;
private String P1;
private String FOB;
private String uomschdl;
private String Outer_L;
private String Outer_W;
private String Outer_H;
private String gw;
private String inner_L;
private String inner_W;
private String inner_H;
private String Casepack;
private String Innerbox;
private String cbm;
private String moq;
private String fobpoint;
public String getItemnmbr() {
return Itemnmbr;
}
public void setItemnmbr(String itemnmbr) {
Itemnmbr = itemnmbr;
}
public String getVendorid() {
return Vendorid;
}
public void setVendorid(String vendorid) {
Vendorid = vendorid;
}
public String getItemdesc() {
return Itemdesc;
}
public void setItemdesc(String itemdesc) {
Itemdesc = itemdesc;
}
public String getH() {
return H;
}
public void setH(String h) {
H = h;
}
public String getW() {
return W;
}
public void setW(String w) {
W = w;
}
public String getD() {
return D;
}
public void setD(String d) {
D = d;
}
public String getP1() {
return P1;
}
public void setP1(String p1) {
P1 = p1;
}
public String getFOB() {
return FOB;
}
public void setFOB(String fob) {
FOB = fob;
}
public String getUomschdl() {
return uomschdl;
}
public void setUomschdl(String uomschdl) {
this.uomschdl = uomschdl;
}
public String getOuter_L() {
return Outer_L;
}
public void setOuter_L(String outer_L) {
Outer_L = outer_L;
}
public String getOuter_W() {
return Outer_W;
}
public void setOuter_W(String outer_W) {
Outer_W = outer_W;
}
public String getOuter_H() {
return Outer_H;
}
public void setOuter_H(String outer_H) {
Outer_H = outer_H;
}
public String getGw() {
return gw;
}
public void setGw(String gw) {
this.gw = gw;
}
public String getInner_L() {
return inner_L;
}
public void setInner_L(String inner_L) {
this.inner_L = inner_L;
}
public String getInner_W() {
return inner_W;
}
public void setInner_W(String inner_W) {
this.inner_W = inner_W;
}
public String getInner_H() {
return inner_H;
}
public void setInner_H(String inner_H) {
this.inner_H = inner_H;
}
public String getCasepack() {
return Casepack;
}
public void setCasepack(String casepack) {
Casepack = casepack;
}
public String getInnerbox() {
return Innerbox;
}
public void setInnerbox(String innerbox) {
Innerbox = innerbox;
}
public String getCbm() {
return cbm;
}
public void setCbm(String cbm) {
this.cbm = cbm;
}
public String getMoq() {
return moq;
}
public void setMoq(String moq) {
this.moq = moq;
}
public String getFobpoint() {
return fobpoint;
}
public void setFobpoint(String fobpoint) {
this.fobpoint = fobpoint;
}
}
***********************************************************************************
2、Action实现类:com.struts.Action/FindQuoteAction.java
***********************************************************************************
package com.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 com.hiernate.persistence.Quote;
import com.hiernate.util.HibernateUtil;
import com.struts.form.QuoteForm;
public class FindQuoteAction extends DispatchAction { //创建FindQuoteAction类继承DispatchAction类
public ActionForward finQuote(ActionMapping mapping, ActionForm form, HttpServletRequest request,HttpServletResponse rsponse) throws Exception {
QuoteForm uf = (QuoteForm)form; //获得QuoteForm对象
String strItem =request.getParameter("itemnmbr");
List list = HibernateUtil.findQuote(strItem);
request.getSession().setAttribute("list", list);
Quote quote = new Quote();
if(list!=null && !list.isEmpty()){ //判断list是否为空
for(int i=0;i<list.size();i++){ //循环遍历集合
quote =(Quote) list.get(i); //list.get()方法返回列表中指定位置元素
//String strItem = quote.getItemnmbr(); //获得User对象的用户名信息
String strVendorid = quote.getVendorid(); //获得User对象的权限信息
String strItemdesc = quote.getItemdesc(); //获得User对象的部门信息
String strH=quote.getH();
String strW=quote.getW();
String strD=quote.getD();
String strP1=quote.getP1();
String strFOB=quote.getFOB();
String strUomschdl=quote.getUomschdl();
String strOuter_L=quote.getOuter_L();
String strOuter_W=quote.getOuter_W();
String strOuter_H=quote.getOuter_H();
String strGw=quote.getGw();
String strInner_L=quote.getInner_L();
String strInner_W=quote.getInner_W();
String strInner_H=quote.getInner_H();
String strCasepack=quote.getCasepack();
String strInnerbox=quote.getInnerbox();
String strCbm=quote.getCbm();
String strMoq=quote.getMoq();
String strFobpoint=quote.getFobpoint();
uf.setVendorid(strVendorid);
uf.setItemdesc(strItemdesc);
uf.setH(strH);
uf.setW(strW);
uf.setD(strD);
uf.setP1(strP1);
uf.setFOB(strFOB);
uf.setUomschdl(strUomschdl);
uf.setOuter_L(strOuter_L);
uf.setOuter_W(strOuter_W);
uf.setOuter_H(strOuter_H);
uf.setGw(strGw);
uf.setInner_L(strInner_L);
uf.setInner_H(strInner_H);
uf.setInner_W(strInner_W);
uf.setCasepack(strCasepack);
uf.setInnerbox(strInnerbox);
uf.setCbm(strCbm);
uf.setMoq(strMoq);
uf.setFobpoint(strFobpoint);
request.getSession().setAttribute("uform", uf); //将uf保存在session中
request.getSession().setAttribute("itemnmbr",strItem);
}
return new ActionForward("/findMenuAction.do?method=findMenu"); //如果用户输入的用户名和密码都正确的话转发到findMenuAction
}
else{
return new ActionForward("/unsuccess.jsp"); //当用户名或密码输入错误是转发到unsuccess.jsp页面
}
}
}
***********************************************************************************
3、com.hiernate.persistence/HibernateUtil.java
***********************************************************************************
public static List findQuote(String strItem) {
Transaction tx = null;
List list = null;
try {
session = hib.openSession(); //调用公共类的开启session方法.
tx = (Transaction) session.beginTransaction(); //开启事物
Query query = session.createQuery("from Quote as Q where Q.Itemnmbr=:strItem"); //应用HQL检索查找满足条件的集合
query.setString("strItem", strItem); //动态绑定参数
list = query.list(); //list方法用来执行HQL语句
tx.commit(); //事务的提交
hib.closeSession(session); //关闭session
} catch (Exception e) {
e.printStackTrace(); //输出异常信息
tx.rollback(); //事务的回滚
}
return list;
}
***********************************************************************************
4、前台页面QuoteManagement/quote_index.jsp
***********************************************************************************
<%@ page language="java" pageEncoding="gb2312"%>
<%@ page import="java.util.List"%>
<%@ page import="com.hiernate.persistence.*"%>
<jsp:directive.page import="com.hiernate.util.HibernateUtil"/>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<head>
<html:base />
<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">
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
}
.style10 {color: #669999}
.style11 {color: #C60001}
.STYLE13 {color: #000000; font-size: 9pt; }
.STYLE14 {
font-size: 9pt;
color: #000000;
}
.STYLE16 {font-size: 9pt}
-->
</style>
<script language="javascript">
function Mycheck()
{
if(form1.itemnmbr.value=="")
{alert("请输入Item Number");form1.itemnmbr.focus();return;}
form1.submit();
}
</script>
<link href="../CSS/style.css" rel="stylesheet" type="text/css">
</head>
<body background="../Images/main_center.jpg">
<table width="801" height="505" border="0" cellpadding="0" cellspacing="0" background="../Images/main_center.JPG">
<tr>
<td height="488" valign="top"><table width="100%" height="84%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td valign="top"><table width="100%" height="119" border="0" cellpadding="-2" cellspacing="-2" background="../images/bbs/bbs_01.gif">
<tr valign="top">
<td width="100%" height="45" background="../Images/main_top.JPG"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<tr>
<td width="5%"><br> <img src="../Images/isexists.gif" width="16" height="16"></td>
<td width="23%" align="left"><br> <b>显示报价</b></td>
<td width="72%" valign="bottom"> </td>
</tr>
</table></td>
</tr>
<tr valign="top">
</tr>
</table>
<table width="60%" height="21%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="69" valign="bottom"><br>
<table width="557" height="40" border="0" cellpadding="-2" cellspacing="-2">
<tr>
<td width="7%" height="24" align="center" valign="middle"> </td>
<td width="20%" height="24" align="center"></td>
<br>
<td width="4%" align="center">
<!--<img src="../Images/modify.gif" width="12" height="12"></td>
-->
<td width="17%" align="center" class="style10"><div align="left">
<%
String currPage = request.getParameter("currPage");
int iCurrPage = 1 ; //定义目前页数,注意初始值不能为0
int pages = 1 ; //定义总页数
int allRecCount = 0 ; //定义表中总的记录数
int recPerPage = 168 ; //定义每页显示的记录数
allRecCount = HibernateUtil.findQCount(); // 查询出总的记录数
pages = (allRecCount - 1)/recPerPage + 1 ; // 计算出总的页数
if(pages == 0){ // 对页数进行有效性处理,使页数的最小值是1
pages = 1;
}
if(currPage != null && !currPage.equalsIgnoreCase("")){
iCurrPage = Integer.parseInt(currPage);
}
List listQuote = HibernateUtil.findQuote((iCurrPage - 1) * recPerPage, recPerPage);
if(!listQuote.isEmpty()&& listQuote.size()>0){
for(int j=0;j<listQuote.size();j++){
Quote quote = (Quote)listQuote.get(j);
}
}
%>
</div></td>
<td width="5%" height="24"><div align="center" class="style10"></div></td>
<td width="30%" height="24"> </td>
<td width="17%" height="24"><div align="center"></div></td>
</tr>
<tr>
<td height="16" colspan="8"></td>
</tr>
</table>
<table width="556" border="0" cellspacing="-2" cellpadding="-2" align="center" >
<tr>
<td><form action="../findQuoteAction.do?method=finQuote" method="post" name="form1">
<table width="100%" border="0" cellspacing="-2" cellpadding="-2" align="center">
<tr>
<td width="2%"> </td>
<td width="23%"> <span class="STYLE13">请输入Item Number:</span></td>
<td width="36%"><input name="itemnmbr" type="text" class="Sytle_text" id="itemnmbr">
<input name="Submit" type="button" class="btn_grey" value="搜索" onClick="Mycheck();"></td>
<td width="12%"> </td>
<td width="10%"> </td>
<td width="17%"><div align="right">
</div></td>
</tr>
</table>
</form></td>
</tr>
</table>
<table width="556" border="0" align="center" cellpadding="-2" cellspacing="-2">
<tr>
<td>
<%if(listQuote.isEmpty()){%>
<table align="center" cellpadding="0" cellspacing="0">
<tr><td><span class="STYLE16">无此Item信息!</span></td>
</tr></table>
<%}else{%>
<table width="97%" height="42" border="1" align="right" cellpadding="-2" cellspacing="-2">
<tr>
<td width="10%"><div align="center" class="STYLE16">Item Number</div></td>
<td width="18%"><div align="center"><span class="STYLE16">Vendor ID</span></div></td>
<td width="20%"><div align="center" class="STYLE16">Item Description</div></td>
<td width="16%"><div align="center"><span class="STYLE16">H</span></div></td>
<td width="6%"><div align="center" class="STYLE16">W</div></td>
<td width="6%"><div align="center" class="STYLE16">D</div></td>
<td width="6%"><div align="center" class="STYLE16">P1</div></td>
<td width="6%"><div align="center" class="STYLE16">FOB</div></td>
<td width="6%"><div align="center" class="STYLE16">UOM</div></td>
<td width="6%"><div align="center" class="STYLE16">fobpoint</div></td>
</tr>
<%
if(!listQuote.isEmpty()&& listQuote.size()>0){
for(int i=0;i<listQuote.size();i++){
Quote quotes = (Quote)listQuote.get(i);
session.setAttribute("quote",quotes);
%>
<tr>
<td><div class="STYLE14"> <%=quotes.getItemnmbr()%></div></td>
<td><div class="STYLE14"> <%=quotes.getVendorid()%></div></td>
<td><div class="STYLE14"> <%=quotes.getItemdesc()%></div></td>
<td><div class="STYLE14"> <%=quotes.getH()%></div></td>
<td><div class="STYLE14"> <%=quotes.getW()%></div></td>
<td><div class="STYLE14"> <%=quotes.getD()%></div></td>
<td><div class="STYLE14"> <%=quotes.getP1()%></div></td>
<td><div class="STYLE14"> <%=quotes.getFOB()%></div></td>
<td><div class="STYLE14"> <%=quotes.getUomschdl()%></div></td>
<td><div class="STYLE14"> <%=quotes.getFobpoint()%></div></td>
<td><div align="center">
<a href="#" onClick="JScrip:window.open('quote_detail.jsp?ID=<%=quotes.getId()
%>','','width=556,height=330');return false">
<img src="../Images/detail.gif" width="16" height="17" border="0"></A></div></td>
<td><div align="center">
<%
String purview = (String)application.getAttribute("Purview");
if(!purview.equalsIgnoreCase("系统")){
%>
<a href="quote_nomodify.jsp">
<img src="../Images/modify.gif" width="12" height="12" border="0"></a></td>
<td>
<a href="quote_nomodify.jsp">
<img src="../Images/del.gif" width="16" height="16" border="0"></a></td>
<%} %>
<%if(purview.equalsIgnoreCase("系统")){ %>
<a href="#" onClick="JScrip:window.open('quote_modify.jsp?ID=<%=quotes.getId()%>','','width=460,height=380');return false">
<img src="../Images/modify.gif" width="12" height="12" border="0"></a>
<td><div align="center">
<a href="quote_del.jsp?ID=<%=quotes.getId()%>&&currPage=<%=iCurrPage%>&link=<%=listQuote.size()%>" onClick="return confirm('是否确认删除?')">
<img src="../Images/del.gif" width="16" height="16" border="0">
</a></div></td>
</div></td>
</tr>
<%}}}%>
</table></td>
</tr>
</table>
<table width="556" border="0" align="center" cellpadding="-2" cellspacing="-2">
<tr>
<td><div align="right">
<span class="STYLE16">
<%
if(recPerPage < allRecCount){
String href = " <a href='quote_index.jsp?currPage=";
StringBuffer sbf = new StringBuffer(); //制作分页条
if(iCurrPage > 1){
sbf.append(href+(iCurrPage - 1)+"'>上一页</a>"); //构造上一页
}
for(int i = 1 ; i <= pages ; i ++){
if(i == iCurrPage){
sbf.append(href+i+"'>["+i+"]</a>"); //追加串
}
else{
sbf.append(href+i+"'>"+i+"</a>");
}
}
if(iCurrPage < pages){
sbf.append(href+(iCurrPage + 1)+"'>下一页</a>"); //构造下一页
}
%>
<%out.print("当前页数:["+iCurrPage+"/"+pages+"]");%>
<%=sbf.toString()%>
<%} }%>
</span></div></td>
</tr>
</table>
</td>
</tr>
</table></td>
</tr>
</table>
</body>
***********************************************************************************
先把偶的代码全帖出来,请JJ帮忙看看:
1、ActionForm:com.struts.Form/QuoteForm.java
**********************************************************************************
package com.struts.form;
import java.sql.Date;
import org.apache.struts.action.ActionForm;
public class QuoteForm extends ActionForm {
private String Itemnmbr;
private String Vendorid;
private String Itemdesc;
private String H;
private String W;
private String D;
private String P1;
private String FOB;
private String uomschdl;
private String Outer_L;
private String Outer_W;
private String Outer_H;
private String gw;
private String inner_L;
private String inner_W;
private String inner_H;
private String Casepack;
private String Innerbox;
private String cbm;
private String moq;
private String fobpoint;
public String getItemnmbr() {
return Itemnmbr;
}
public void setItemnmbr(String itemnmbr) {
Itemnmbr = itemnmbr;
}
public String getVendorid() {
return Vendorid;
}
public void setVendorid(String vendorid) {
Vendorid = vendorid;
}
public String getItemdesc() {
return Itemdesc;
}
public void setItemdesc(String itemdesc) {
Itemdesc = itemdesc;
}
public String getH() {
return H;
}
public void setH(String h) {
H = h;
}
public String getW() {
return W;
}
public void setW(String w) {
W = w;
}
public String getD() {
return D;
}
public void setD(String d) {
D = d;
}
public String getP1() {
return P1;
}
public void setP1(String p1) {
P1 = p1;
}
public String getFOB() {
return FOB;
}
public void setFOB(String fob) {
FOB = fob;
}
public String getUomschdl() {
return uomschdl;
}
public void setUomschdl(String uomschdl) {
this.uomschdl = uomschdl;
}
public String getOuter_L() {
return Outer_L;
}
public void setOuter_L(String outer_L) {
Outer_L = outer_L;
}
public String getOuter_W() {
return Outer_W;
}
public void setOuter_W(String outer_W) {
Outer_W = outer_W;
}
public String getOuter_H() {
return Outer_H;
}
public void setOuter_H(String outer_H) {
Outer_H = outer_H;
}
public String getGw() {
return gw;
}
public void setGw(String gw) {
this.gw = gw;
}
public String getInner_L() {
return inner_L;
}
public void setInner_L(String inner_L) {
this.inner_L = inner_L;
}
public String getInner_W() {
return inner_W;
}
public void setInner_W(String inner_W) {
this.inner_W = inner_W;
}
public String getInner_H() {
return inner_H;
}
public void setInner_H(String inner_H) {
this.inner_H = inner_H;
}
public String getCasepack() {
return Casepack;
}
public void setCasepack(String casepack) {
Casepack = casepack;
}
public String getInnerbox() {
return Innerbox;
}
public void setInnerbox(String innerbox) {
Innerbox = innerbox;
}
public String getCbm() {
return cbm;
}
public void setCbm(String cbm) {
this.cbm = cbm;
}
public String getMoq() {
return moq;
}
public void setMoq(String moq) {
this.moq = moq;
}
public String getFobpoint() {
return fobpoint;
}
public void setFobpoint(String fobpoint) {
this.fobpoint = fobpoint;
}
}
***********************************************************************************
2、Action实现类:com.struts.Action/FindQuoteAction.java
***********************************************************************************
package com.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 com.hiernate.persistence.Quote;
import com.hiernate.util.HibernateUtil;
import com.struts.form.QuoteForm;
public class FindQuoteAction extends DispatchAction { //创建FindQuoteAction类继承DispatchAction类
public ActionForward finQuote(ActionMapping mapping, ActionForm form, HttpServletRequest request,HttpServletResponse rsponse) throws Exception {
QuoteForm uf = (QuoteForm)form; //获得QuoteForm对象
String strItem =request.getParameter("itemnmbr");
List list = HibernateUtil.findQuote(strItem);
request.getSession().setAttribute("list", list);
Quote quote = new Quote();
if(list!=null && !list.isEmpty()){ //判断list是否为空
for(int i=0;i<list.size();i++){ //循环遍历集合
quote =(Quote) list.get(i); //list.get()方法返回列表中指定位置元素
//String strItem = quote.getItemnmbr(); //获得User对象的用户名信息
String strVendorid = quote.getVendorid(); //获得User对象的权限信息
String strItemdesc = quote.getItemdesc(); //获得User对象的部门信息
String strH=quote.getH();
String strW=quote.getW();
String strD=quote.getD();
String strP1=quote.getP1();
String strFOB=quote.getFOB();
String strUomschdl=quote.getUomschdl();
String strOuter_L=quote.getOuter_L();
String strOuter_W=quote.getOuter_W();
String strOuter_H=quote.getOuter_H();
String strGw=quote.getGw();
String strInner_L=quote.getInner_L();
String strInner_W=quote.getInner_W();
String strInner_H=quote.getInner_H();
String strCasepack=quote.getCasepack();
String strInnerbox=quote.getInnerbox();
String strCbm=quote.getCbm();
String strMoq=quote.getMoq();
String strFobpoint=quote.getFobpoint();
uf.setVendorid(strVendorid);
uf.setItemdesc(strItemdesc);
uf.setH(strH);
uf.setW(strW);
uf.setD(strD);
uf.setP1(strP1);
uf.setFOB(strFOB);
uf.setUomschdl(strUomschdl);
uf.setOuter_L(strOuter_L);
uf.setOuter_W(strOuter_W);
uf.setOuter_H(strOuter_H);
uf.setGw(strGw);
uf.setInner_L(strInner_L);
uf.setInner_H(strInner_H);
uf.setInner_W(strInner_W);
uf.setCasepack(strCasepack);
uf.setInnerbox(strInnerbox);
uf.setCbm(strCbm);
uf.setMoq(strMoq);
uf.setFobpoint(strFobpoint);
request.getSession().setAttribute("uform", uf); //将uf保存在session中
request.getSession().setAttribute("itemnmbr",strItem);
}
return new ActionForward("/findMenuAction.do?method=findMenu"); //如果用户输入的用户名和密码都正确的话转发到findMenuAction
}
else{
return new ActionForward("/unsuccess.jsp"); //当用户名或密码输入错误是转发到unsuccess.jsp页面
}
}
}
***********************************************************************************
3、com.hiernate.persistence/HibernateUtil.java
***********************************************************************************
public static List findQuote(String strItem) {
Transaction tx = null;
List list = null;
try {
session = hib.openSession(); //调用公共类的开启session方法.
tx = (Transaction) session.beginTransaction(); //开启事物
Query query = session.createQuery("from Quote as Q where Q.Itemnmbr=:strItem"); //应用HQL检索查找满足条件的集合
query.setString("strItem", strItem); //动态绑定参数
list = query.list(); //list方法用来执行HQL语句
tx.commit(); //事务的提交
hib.closeSession(session); //关闭session
} catch (Exception e) {
e.printStackTrace(); //输出异常信息
tx.rollback(); //事务的回滚
}
return list;
}
***********************************************************************************
4、前台页面QuoteManagement/quote_index.jsp
***********************************************************************************
<%@ page language="java" pageEncoding="gb2312"%>
<%@ page import="java.util.List"%>
<%@ page import="com.hiernate.persistence.*"%>
<jsp:directive.page import="com.hiernate.util.HibernateUtil"/>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<head>
<html:base />
<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">
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
}
.style10 {color: #669999}
.style11 {color: #C60001}
.STYLE13 {color: #000000; font-size: 9pt; }
.STYLE14 {
font-size: 9pt;
color: #000000;
}
.STYLE16 {font-size: 9pt}
-->
</style>
<script language="javascript">
function Mycheck()
{
if(form1.itemnmbr.value=="")
{alert("请输入Item Number");form1.itemnmbr.focus();return;}
form1.submit();
}
</script>
<link href="../CSS/style.css" rel="stylesheet" type="text/css">
</head>
<body background="../Images/main_center.jpg">
<table width="801" height="505" border="0" cellpadding="0" cellspacing="0" background="../Images/main_center.JPG">
<tr>
<td height="488" valign="top"><table width="100%" height="84%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td valign="top"><table width="100%" height="119" border="0" cellpadding="-2" cellspacing="-2" background="../images/bbs/bbs_01.gif">
<tr valign="top">
<td width="100%" height="45" background="../Images/main_top.JPG"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<tr>
<td width="5%"><br> <img src="../Images/isexists.gif" width="16" height="16"></td>
<td width="23%" align="left"><br> <b>显示报价</b></td>
<td width="72%" valign="bottom"> </td>
</tr>
</table></td>
</tr>
<tr valign="top">
</tr>
</table>
<table width="60%" height="21%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="69" valign="bottom"><br>
<table width="557" height="40" border="0" cellpadding="-2" cellspacing="-2">
<tr>
<td width="7%" height="24" align="center" valign="middle"> </td>
<td width="20%" height="24" align="center"></td>
<br>
<td width="4%" align="center">
<!--<img src="../Images/modify.gif" width="12" height="12"></td>
-->
<td width="17%" align="center" class="style10"><div align="left">
<%
String currPage = request.getParameter("currPage");
int iCurrPage = 1 ; //定义目前页数,注意初始值不能为0
int pages = 1 ; //定义总页数
int allRecCount = 0 ; //定义表中总的记录数
int recPerPage = 168 ; //定义每页显示的记录数
allRecCount = HibernateUtil.findQCount(); // 查询出总的记录数
pages = (allRecCount - 1)/recPerPage + 1 ; // 计算出总的页数
if(pages == 0){ // 对页数进行有效性处理,使页数的最小值是1
pages = 1;
}
if(currPage != null && !currPage.equalsIgnoreCase("")){
iCurrPage = Integer.parseInt(currPage);
}
List listQuote = HibernateUtil.findQuote((iCurrPage - 1) * recPerPage, recPerPage);
if(!listQuote.isEmpty()&& listQuote.size()>0){
for(int j=0;j<listQuote.size();j++){
Quote quote = (Quote)listQuote.get(j);
}
}
%>
</div></td>
<td width="5%" height="24"><div align="center" class="style10"></div></td>
<td width="30%" height="24"> </td>
<td width="17%" height="24"><div align="center"></div></td>
</tr>
<tr>
<td height="16" colspan="8"></td>
</tr>
</table>
<table width="556" border="0" cellspacing="-2" cellpadding="-2" align="center" >
<tr>
<td><form action="../findQuoteAction.do?method=finQuote" method="post" name="form1">
<table width="100%" border="0" cellspacing="-2" cellpadding="-2" align="center">
<tr>
<td width="2%"> </td>
<td width="23%"> <span class="STYLE13">请输入Item Number:</span></td>
<td width="36%"><input name="itemnmbr" type="text" class="Sytle_text" id="itemnmbr">
<input name="Submit" type="button" class="btn_grey" value="搜索" onClick="Mycheck();"></td>
<td width="12%"> </td>
<td width="10%"> </td>
<td width="17%"><div align="right">
</div></td>
</tr>
</table>
</form></td>
</tr>
</table>
<table width="556" border="0" align="center" cellpadding="-2" cellspacing="-2">
<tr>
<td>
<%if(listQuote.isEmpty()){%>
<table align="center" cellpadding="0" cellspacing="0">
<tr><td><span class="STYLE16">无此Item信息!</span></td>
</tr></table>
<%}else{%>
<table width="97%" height="42" border="1" align="right" cellpadding="-2" cellspacing="-2">
<tr>
<td width="10%"><div align="center" class="STYLE16">Item Number</div></td>
<td width="18%"><div align="center"><span class="STYLE16">Vendor ID</span></div></td>
<td width="20%"><div align="center" class="STYLE16">Item Description</div></td>
<td width="16%"><div align="center"><span class="STYLE16">H</span></div></td>
<td width="6%"><div align="center" class="STYLE16">W</div></td>
<td width="6%"><div align="center" class="STYLE16">D</div></td>
<td width="6%"><div align="center" class="STYLE16">P1</div></td>
<td width="6%"><div align="center" class="STYLE16">FOB</div></td>
<td width="6%"><div align="center" class="STYLE16">UOM</div></td>
<td width="6%"><div align="center" class="STYLE16">fobpoint</div></td>
</tr>
<%
if(!listQuote.isEmpty()&& listQuote.size()>0){
for(int i=0;i<listQuote.size();i++){
Quote quotes = (Quote)listQuote.get(i);
session.setAttribute("quote",quotes);
%>
<tr>
<td><div class="STYLE14"> <%=quotes.getItemnmbr()%></div></td>
<td><div class="STYLE14"> <%=quotes.getVendorid()%></div></td>
<td><div class="STYLE14"> <%=quotes.getItemdesc()%></div></td>
<td><div class="STYLE14"> <%=quotes.getH()%></div></td>
<td><div class="STYLE14"> <%=quotes.getW()%></div></td>
<td><div class="STYLE14"> <%=quotes.getD()%></div></td>
<td><div class="STYLE14"> <%=quotes.getP1()%></div></td>
<td><div class="STYLE14"> <%=quotes.getFOB()%></div></td>
<td><div class="STYLE14"> <%=quotes.getUomschdl()%></div></td>
<td><div class="STYLE14"> <%=quotes.getFobpoint()%></div></td>
<td><div align="center">
<a href="#" onClick="JScrip:window.open('quote_detail.jsp?ID=<%=quotes.getId()
%>','','width=556,height=330');return false">
<img src="../Images/detail.gif" width="16" height="17" border="0"></A></div></td>
<td><div align="center">
<%
String purview = (String)application.getAttribute("Purview");
if(!purview.equalsIgnoreCase("系统")){
%>
<a href="quote_nomodify.jsp">
<img src="../Images/modify.gif" width="12" height="12" border="0"></a></td>
<td>
<a href="quote_nomodify.jsp">
<img src="../Images/del.gif" width="16" height="16" border="0"></a></td>
<%} %>
<%if(purview.equalsIgnoreCase("系统")){ %>
<a href="#" onClick="JScrip:window.open('quote_modify.jsp?ID=<%=quotes.getId()%>','','width=460,height=380');return false">
<img src="../Images/modify.gif" width="12" height="12" border="0"></a>
<td><div align="center">
<a href="quote_del.jsp?ID=<%=quotes.getId()%>&&currPage=<%=iCurrPage%>&link=<%=listQuote.size()%>" onClick="return confirm('是否确认删除?')">
<img src="../Images/del.gif" width="16" height="16" border="0">
</a></div></td>
</div></td>
</tr>
<%}}}%>
</table></td>
</tr>
</table>
<table width="556" border="0" align="center" cellpadding="-2" cellspacing="-2">
<tr>
<td><div align="right">
<span class="STYLE16">
<%
if(recPerPage < allRecCount){
String href = " <a href='quote_index.jsp?currPage=";
StringBuffer sbf = new StringBuffer(); //制作分页条
if(iCurrPage > 1){
sbf.append(href+(iCurrPage - 1)+"'>上一页</a>"); //构造上一页
}
for(int i = 1 ; i <= pages ; i ++){
if(i == iCurrPage){
sbf.append(href+i+"'>["+i+"]</a>"); //追加串
}
else{
sbf.append(href+i+"'>"+i+"</a>");
}
}
if(iCurrPage < pages){
sbf.append(href+(iCurrPage + 1)+"'>下一页</a>"); //构造下一页
}
%>
<%out.print("当前页数:["+iCurrPage+"/"+pages+"]");%>
<%=sbf.toString()%>
<%} }%>
</span></div></td>
</tr>
</table>
</td>
</tr>
</table></td>
</tr>
</table>
</body>
***********************************************************************************