求大神指教哦!

chen_3010 2012-08-24 11:40:44
这里是 Jsp页面 list.jsp 显示所有的报价历史

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>历史订单</title>
<script type="text/javascript">

function back(){
history.go(-1);
}

//详细信息
function findByIdFromshow(form,id){
document.getElementById('filterOfferDetailedId').value=id;
alert(id);
var url='<s:url action="show" namespace="/quote"/>';
form.action = url;
form.submit();
}
</script>

</head>

<body>
<s:hidden id="filterOfferDetailedId" name="filterOfferDetailedId" value=""/>
<form>
<s:token/>
<table align="center" border="">
<tr>
<td align="center" colspan="6"><h5>历史报价</h5></td>
</tr>
<tr>
<td><s:text name="序号"/></td>
<td><s:text name="商品名称"/></td>
<td><s:text name="数量"/></td>
<td><s:text name="单价(元)"/></td>
<td><s:text name="金额(元)"/></td>
<td><s:text name="报价日期"/></td>

</tr>
<s:iterator value="pagination.items" status="status">
<tr>
<td><a href="javascript:findByIdFromshow(document.forms[0],'<c:out value="${offerDetailedId}"/>');"><s:property value="offerDetailedId" /></a></td>
<td><s:property value="productName" /></td>
<td><s:property value="productNum" /></td>
<td><s:property value="productPrice" /></td>
<td><s:property value="productNum * productPrice" /></td>
<td><s:property value="createDate"/></td>
</tr>
</s:iterator>
</table>
</form>
</body>
</html>
这里是Action层:

package com.shhelian.app.action.chance;

import java.text.SimpleDateFormat;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.shhelian.app.model.QuoteDetailed;
import com.shhelian.app.model.SellChance;
import com.shhelian.app.model.SellOrder;
import com.shhelian.app.service.chance.QuoteDetailedService;
import com.shhelian.modules.orm.PaginationSupport;
import com.shhelian.modules.web.struts2.BaseCRUDAction;


@Component("quoteDetailed")
@Scope("prototype")
public class QuoteDetailedAction extends BaseCRUDAction<QuoteDetailed> {

static Logger logger = Logger.getLogger(QuoteDetailedAction.class.getName());

@Autowired
private QuoteDetailedService entityService;

// model
private QuoteDetailed entity;

private String filterOfferDetailedId;

private String filterProductName;


@Override
protected void prepareModel() throws Exception {
logger.debug("==========> prepareModel");
if (StringUtils.isNotBlank(filterOfferDetailedId)) {
System.out.println(filterOfferDetailedId);
entity = entityService.findById(filterOfferDetailedId);
} else {
entity = new QuoteDetailed();
}
}

/**
* 集合列表
*/
@Override
public String list(){
try{
PaginationSupport<QuoteDetailed> ps = entityService.findPage(
getPagination().getPageSize(),
getPagination().getStartIndex(),
filterProductName);
setPagination(ps);
return RELOAD;
}catch (Exception e) {
e.printStackTrace();
}
return ERROR;
}
/**
* 详细信息
*/
@Override
public String show(){
logger.debug("=====================" + filterOfferDetailedId);
System.out.println("***************************" + filterOfferDetailedId);
entityService.findById(filterOfferDetailedId);

return RELOAD;
}

/**
* 保存
*/
@Override
public String insertSubmit() throws Exception {
logger.debug("==========> insertSubmit");
try {
entityService.save(entity);
return RELOAD;
} catch (Exception ex) {
ex.getStackTrace();
return ERROR;
}
}


@Override
public QuoteDetailed getModel() {
return entity;
}

public String getFilterOfferDetailedId() {
return filterOfferDetailedId;
}

public void setFilterOfferDetailedId(String filterOfferDetailedId) {
this.filterOfferDetailedId = filterOfferDetailedId;
}

public String getFilterProductName() {
return filterProductName;
}

public void setFilterProductName(String filterProductName) {
this.filterProductName = filterProductName;
}

}

页面报错:

java.lang.IllegalArgumentException: id to load is required for loading
org.hibernate.event.LoadEvent.<init>(LoadEvent.java:74)
org.hibernate.event.LoadEvent.<init>(LoadEvent.java:56)
org.hibernate.impl.SessionImpl.get(SessionImpl.java:840)
org.hibernate.impl.SessionImpl.get(SessionImpl.java:836)
org.springframework.orm.hibernate3.HibernateTemplate$1.doInHibernate(HibernateTemplate.java:531)
org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)


错误的原始是我Action层里的Id为Null, 可是我页面明明获取到Id了 alert();了下。 Id是有值的, 为什么到Action层就为Null , 求大神指教哦!
...全文
90 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
chen_3010 2012-08-24
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]
没有set方法啊
[/Quote]

有的。 在Action层最下面 , 问题我已经解决了。 楼下的那个仁兄给出的答案是正确的。
chen_3010 2012-08-24
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 的回复:]
因为你的id没有被form包括,把这一行
<s:hidden id="filterOfferDetailedId" name="filterOfferDetailedId" value=""/>
放到form中就可以了
[/Quote]

蒽蒽 、 是的。 我刚发完帖子 就找到错误原因。 呵呵。 找到错误原因后我第一时间就把解决方法公布出来了 。 还是很谢谢你 。
liangtu 2012-08-24
  • 打赏
  • 举报
回复
因为你的id没有被form包括,把这一行
<s:hidden id="filterOfferDetailedId" name="filterOfferDetailedId" value=""/>
放到form中就可以了

  • 打赏
  • 举报
回复
没有set方法啊
chen_3010 2012-08-24
  • 打赏
  • 举报
回复
问题的原因我找到了。 是在我jsp页面那里 有个隐藏域<s:hidden> 我放在了<form>外面 改成放在里面就可以了。 郁闷 ,找了半天都没有找到什么原因。 发完帖子后稍微的看了下刚才发的代码就找到错误原因。

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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