概述
8) ,
说的不如给你们看
一:接口BO DmOrderPriceImpl
public List queryChargeType(int priceId) {
// TODO 自动生成方法存根
return this.dmOrderPriceDao.queryDmChargeType(priceId);
}
二:接口 Dao DmOrderPriceDaoImpl
public List queryDmChargeType(int priceId) {
// TODO 自动生成方法存根
String hql="from DmChargeType as d left join fetch d.dmOrderPrice as dp where dp.id="+priceId;
return this.hibernateTemplate.find(hql);
}
三:配置文件
<?xml version="1.0"?>
<!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 - Hibernate Tools
-->
<hibernate-mapping>
<class name="com.superman.model.DmChargeType" table="dm_chargeType" catalog="sanco_superman">
<id name="id" type="java.lang.Integer">
<column name="id" />
<generator class="identity" />
</id>
<many-to-one name="dmOrderPrice" class="com.superman.model.DmOrderPrice" fetch="select">
<column name="dm_priceId" />
</many-to-one>
<property name="max" type="java.lang.Integer">
<column name="max" />
</property>
<property name="min" type="java.lang.Integer">
<column name="min" />
</property>
<property name="cost" type="java.lang.Float">
<column name="cost" precision="9" scale="3" />
</property>
</class>
</hibernate-mapping>
主键表:
<hibernate-mapping>
<class name="com.superman.model.DmOrderPrice" table="dm_order_price" catalog="sanco_superman">
<id name="id" type="java.lang.Integer">
<column name="id" />
<generator class="identity" />
</id>
<property name="price" type="java.lang.Float">
<column name="price" precision="9" scale="3" />
</property>
<set name="dmChargeTypes" inverse="true">
<key>
<column name="dm_priceId" />
</key>
<one-to-many class="com.superman.model.DmChargeType" />
</set>
</class>
</hibernate-mapping>
struts.config
<form-bean name="dmOrderPriceForm" type="com.sanco.supperman.struts.form.DmOrderPriceForm" />
<action
attribute="dmOrderPriceForm"
name="dmOrderPriceForm"
parameter="method"
path="/xwfbadmin/admin/manage/dmManager/addChargeType"
scope="request"
type="com.sanco.supperman.struts.action.AddChargeTypeAction">
<forward name="init" path="/xwfbadmin/admin/manage/dmManager/addChargeType.do?method=init" />
<forward name="success" path="/xwfbadmin/admin/manage/dmManager/dmChargeType_add.jsp" />
</action>
四:页面
提交过来的页面(没有javascript --|||,这我还是晓得看的)
<%@ page language="java" pageEncoding="gbk"
contentType="text/html; charset=gbk"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>提成折扣设置</title>
</head>
<body>
<form action="addDmprice.do" method="post" name="form1">
<table align="center">
<tr>
<td>价格:</td><td><input type="text" name="price" /></td>
</tr>
<tr>
<td><input type="submit" value="添加价格" /></td>
</tr>
</table>
</form>
<logic:present name="emplist" scope="request">
<table width="500" align="center">
<tr>
<td background="#fffff">编号</td>
<td background="#fffff">价格</td>
<td background="#fffff">操作</td>
</tr>
<logic:iterate id="emp" name="emplist" scope="request">
<tr>
<td>
<bean:write name="emp" property="id" />
</td>
<td> <bean:write name="emp" property="price" /></td>
<td><a href="updateOrderPrice.do?id=<bean:write name="emp" property="id" />&price=<bean:write name="emp" property="price" />" >修改</a[color=green]>|<a href="addChargeType.do?method=init&id=<bean:write name="emp" property="id" />" [/color]>设定折扣区间</a></td>
</tr>
</logic:iterate>
</table>
</logic:present>
</body>
</html>
显示成功的页面
<%@ page language="java" pageEncoding="gbk"
contentType="text/html; charset=gbk"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>提成折扣设置</title>
<style type="text/css">
<!--
body,td,th {
font-family: 宋体;
font-size: 12px;
}
body {
margin-left: 0px;
margin-top: 20px;
margin-right: 0px;
margin-bottom: 20px;
}
-->
</style>
</head>
<body>
<form action="addChargeType.do?method=add&id=${priceId}" method="post" name="form1">
<table align="center">
<input type="hidden" name="id" value="${priceId}" />
<tr>
<td>最大份数:</td><td><input type="text" name="max" /></td>
</tr>
<tr>
<td>最小份数:</td><td><input type="text" name="min" /></td>
</tr>
<tr>
<td>区间折扣:</td><td><input type="text" name="cost" /></td>
</tr>
<tr>
<td><input type="submit" value="设置折扣区间" /></td>
</tr>
</table>
</form>
<logic:present name="emplist" scope="request">
<table width="500" align="center">
<tr>
<td background="#fffff">编号</td>
<td background="#fffff">最大份数</td>
<td background="#fffff">最小份数</td>
<td background="#fffff">区间折扣</td>
<td background="#fffff">价格</td>
<td background="#fffff">操作</td>
</tr>
<logic:iterate id="emp" name="emplist" scope="request">
<tr>
<td>
${emp.id}
</td>
<td> <bean:write name="emp" property="max" /></td>
<td>${emp.min}</td>
<td>${emp.cost}</td>
<td>${emp.dmOrderPrice.price}</td>
<td><a href="addChargeType.do?method=delete&typeid=${emp.id}&priceid=${priceId}">删除</a></td>
</tr>
</logic:iterate>
</table>
</logic:present>
</body>
</html>
五:action
public class AddChargeTypeAction extends DispatchAction {
/*
* Generated Methods
*/
private Object getBean(String name)
{
return MyBeanDelegate.getInstance().getBean(name);
}
private IDmOrderPriceBo dmOrderPriceBo=(IDmOrderPriceBo)getBean("dmOrderPricebo");
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward init(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
DmOrderPriceForm dmOrderPriceForm = (DmOrderPriceForm) form;// TODO Auto-generated method stub
//查询所有这个价格的折扣区间
String id=request.getParameter("id");
List list=null;
[color=green]list=dmOrderPriceBo.queryChargeType(Integer.valueOf(id));[/color] request.setAttribute("emplist", list);
request.setAttribute("priceId", id);
return mapping.findForward("success");
}
}
-----------------------------------------------------------------
我页面上是用的EL表达式打出来的,去掉也好了,不知道EL为什么不行??完全没得道理。
能够看出原因的,我称他为神,女的就以身相许!
最后
以上就是甜美帆布鞋为你收集整理的关于struts action 提交2次的问题 ---继续的全部内容,希望文章能够帮你解决关于struts action 提交2次的问题 ---继续所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复