用ssh框架做商品信息修改,不能获取数据和提交,帮忙看看哪里出错了,如何修改

xlr4329 2018-04-27 12:10:41
其他功能能都可以运行,以下是修改功能的代码
goodsAction.java部分的修改代码
public String goodsUpdate()
{

Map request=(Map)ServletActionContext.getContext().get("request");
TGoods goods=goodsDAO.findById(goodsId);
request.put("goods", goods);
goods.setGoodsCatelogId(goodsCatelogId);
goods.setGoodsName(goodsName);
goods.setGoodsMiaoshu(goodsMiaoshu);
goods.setGoodsPic(fujian);
goods.setGoodsShichangjia(goodsShichangjia);
if(goodsTejia==0)//特格为0表示没有特价
{
goods.setGoodsTejia(goodsShichangjia);// 如果不是特价鲜花。把这个鲜花的特价设置为市场价格
goods.setGoodsIsnottejia("no");
}
else
{
goods.setGoodsTejia(goodsTejia);
goods.setGoodsIsnottejia("yes");
}

goods.setGoodsKucun(goodsKucun);
goods.setGoodsDel("no");

goodsDAO.save(goods);
this.setMessage("操作成功");
this.setPath("goodsManaNoTejia.action");
return "succeed";
}
TGoodsDAO.java修改部分:
public void update(TGoods transientInstance)
{
log.debug("saving TGoods instance");
try
{
getHibernateTemplate().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re)
{
log.error("save failed", re);
throw re;
}
}
JSP中修改按钮的代码
function goodsUpdate(goodsId)
{
var url="<%=path %>/admin/goods/goodsUpdate.jsp?goodsId="+goodsId;
window.location.href=url;
}
<a href="#" onclick="goodsUpdate(<s:property value="#goods.goodsId"/>)" class="pn-loperator">修改</a>
修改界面的JSP goodsUpdate.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ page isELIgnored="false" %>
<%@ taglib uri="http://java.fckeditor.net" prefix="FCK"%>

<%
String path = request.getContextPath();
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<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="<%=path %>/css/base.css" />

<script type='text/javascript' src='<%=path %>/dwr/interface/catelogService.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/engine.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/util.js'></script>
<script type="text/javascript" src="<%=path %>/js/popup.js"></script>

<script language="javascript">
var i=0;
function goodsCatelogSelect()
{
if(i==0)
{
document.getElementById("indicator").style.display="block";
catelogService.findAllCatelog(callback);
i=1;
}

}

function callback(data)
{
document.getElementById("indicator").style.display="none";
//document.getElementById("goodsCatelogId1").style.display="none";
DWRUtil.addOptions("goodsCatelogId",data,"catelogId","catelogName");
//document.getElementById("goodsCatelogId").style.display="block";
}

function up()
{
var pop=new Popup({ contentType:1,isReloadOnClose:false,width:400,height:200});
pop.setContent("contentUrl","<%=path %>/upload/upload.jsp");
pop.setContent("title","文件上传");
pop.build();
pop.show();
}


function check()
{
if(document.formUpdate.goodsCatelogId.value==0)
{
alert("请选择类别");
return false;
}
if(document.formUpdate.goodsName.value=="")
{
alert("请填写鲜花名称");
return false;
}
if(document.formUpdate.goodsShichangjia.value=="")
{
alert("请填写鲜花价格");
return false;
}
if(document.formUpdate.goodsTejia.value=="")
{
alert("请填写鲜花特价");
return false;
}
document.formUpdate.submit();
}
</script>
</head>

<body leftmargin="2" topmargin="9" background='<%=path %>/img/allbg.gif'>
<form action="<%=path %>/goodsUpdate.action" name="formUpdate" method="post" enctype="multipart/form-data">
<table width="98%" align="center" border="0" cellpadding="4" cellspacing="1" bgcolor="#afeeee" style="margin-bottom:8px">
<tr bgcolor="#87e0fa">
<td colspan="3" background="<%=path %>/img/wbg.gif" class='title'><span>鲜花修改</span></td>
</tr>
<tr align='center' bgcolor="#FFFFFF" onMouseMove="javascript:this.bgColor='red';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
<td width="25%" bgcolor="#FFFFFF" align="right">
鲜花类别:
</td>
<td width="75%" bgcolor="#FFFFFF" align="left">
<table>
<tr>
<td>
<select name="goodsCatelogId" id="goodsCatelogId" onclick="goodsCatelogSelect()">
<option value="0">--请选择鲜花类别--</option>
</select>
</td>
<td>
<img id="indicator" src="<%=path %>/img/loading.gif" style="display:none"/>
</td>
</tr>
</table>
</td>
</tr>
<tr align='center' bgcolor="#FFFFFF" onMouseMove="javascript:this.bgColor='red';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
<td width="25%" bgcolor="#FFFFFF" align="right">
鲜花名称:
</td>
<td width="75%" bgcolor="#FFFFFF" align="left">
<input type="text" name="goodsName" <s:property value="${goods.goodsName}"/>size="20"/>
</td>
</tr>
<tr align='center' bgcolor="#FFFFFF" onMouseMove="javascript:this.bgColor='red';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
<td width="25%" bgcolor="#FFFFFF" align="right">
鲜花描述:
</td>
<td width="75%" bgcolor="#FFFFFF" align="left">
<FCK:editor instanceName="goodsMiaoshu" basePath="/fckeditor" width="500" height="200" value="${goods.goodsMiaoshu }" toolbarSet="Basic">
</FCK:editor>
</td>
</tr>
<tr align='center' bgcolor="#FFFFFF" onMouseMove="javascript:this.bgColor='red';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
<td width="25%" bgcolor="#FFFFFF" align="right">
鲜花图片:
</td>
<td width="75%" bgcolor="#FFFFFF" align="left">
<input type="text" name="fujian" id="fujian" size="30" readonly="readonly"/>
<input type="button" value="上传" onclick="up()"/>
<input type="hidden" name="fujianYuanshiming" id="fujianYuanshiming"/>
</td>
</tr>
<tr align='center' bgcolor="#FFFFFF" onMouseMove="javascript:this.bgColor='red';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
<td width="25%" bgcolor="#FFFFFF" align="right">
市场价格:
</td>
<td width="75%" bgcolor="#FFFFFF" align="left">
<input type="text" name="goodsShichangjia" value="${goods.goodsShichangjia}"size="20" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"/>
</td>
</tr>
<tr style="display: none" align='center' bgcolor="#FFFFFF" onMouseMove="javascript:this.bgColor='red';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
<td width="25%" bgcolor="#FFFFFF" align="right">
特格:
</td>
<td width="75%" bgcolor="#FFFFFF" align="left">
<input type="text" name="goodsTejia" size="20" value="0" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"/>
(<font color="red">特格为0表示没有特价</font>)
</td>
</tr>
<tr align='center' bgcolor="#FFFFFF" onMouseMove="javascript:this.bgColor='red';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
<td width="25%" bgcolor="#FFFFFF" align="right">
库存:
</td>
<td width="75%" bgcolor="#FFFFFF" align="left">
<input type="text" name="goodsKucun" size="20" value="${goods.goodsKucun}"onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"/>
</td>
</tr>
<tr align='center' bgcolor="#FFFFFF" onMouseMove="javascript:this.bgColor='red';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
<td width="25%" bgcolor="#FFFFFF" align="right">
 
</td>
<td width="75%" bgcolor="#FFFFFF" align="left">
<input type="button" value="提交" onclick="check()"/> 
<input type="reset" value="重置"/> 
</td>
</tr>
</table>
</form>
</body>
</html>
</body>
</html>
提交以后成这样
...全文
1562 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
QWERT4745 2018-04-27
  • 打赏
  • 举报
回复
结合struts.xml看下,namespace是什么,你的url没有体现出来
xlr4329 2018-04-27
  • 打赏
  • 举报
回复
能不能帮我看下?我改了路径也是不行的
QWERT4745 2018-04-27
  • 打赏
  • 举报
回复
<form action="<%=path %>/goodsUpdate.action">路径写错了,找不到这个action
xlr4329 2018-04-27
  • 打赏
  • 举报
回复
action的配置 <bean id="TGoodsDAO" class="com.dao.TGoodsDAO"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> </bean> <bean id="goodsAction" class="com.action.goodsAction" scope="prototype"> <property name="goodsDAO"> <ref bean="TGoodsDAO" /> </property> <property name="catelogDAO"> <ref bean="TCatelogDAO" /> </property> </bean>
dream1827143 2018-04-27
  • 打赏
  • 举报
回复
action的 bean 配置对了么
xlr4329 2018-04-27
  • 打赏
  • 举报
回复
struts.xml的这部分 <action name="goodsNoTejiaAdd" class="goodsAction" method="goodsNoTejiaAdd"> </action> <action name="goodsNoTejiaDel" class="goodsAction" method="goodsNoTejiaDel"> </action> <action name="goodsUpdate" class="goodsAction" method="goodsUpdate"> </action> <action name="goodsManaNoTejia" class="goodsAction" method="goodsManaNoTejia"> <result name="success">/admin/goods/goodsManaNoTejia.jsp</result> </action> <action name="goodsShezhiTejia" class="goodsAction" method="goodsShezhiTejia"> <result name="success">/common/succ.jsp</result> </action>

50,752

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧