67,513
社区成员
发帖
与我相关
我的任务
分享
<html>
<head>
<title>公告添加</title>
</head>
<s:head/>
<body>
<h5 align="center">添加公告</h5>
<table align="center" border="1" width="40%">
<center>
<s:form action="dormNoticeControl!addNotice.action" >
<s:textfield name="dormNoticeinfo.title" label="公告题目"/>
<s:textfield name="dormNoticeinfo.type" label="公告类型"/>
<s:textarea name="dormNoticeinfo.content" rows="5" cols="20" label="公告内容"/>
<s:textfield name="dormNoticeinfo.issuer" label="发布人"/>
<s:textfield name="dormNoticeinfo.published" label="发布时间"/>
<tr>
<td colspan="2" align="center">
<s:submit theme="simple" value="保存"/>
<s:reset theme="simple" value="重置"/>
</td>
</tr>
</s:form>
</center>
</table>
</body>
</html>
public void addNotice(AbstractdormNoticeInfo dormNoticeinfo) { //添加新的公告
Session session=getSession();
Transaction tra=session.beginTransaction();
System.out.println("dormNotice="+dormNoticeinfo);
session.save(dormNoticeinfo);
tra.commit();
session.close();
}
dormNotice=null
2010-7-4 9:00:38 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet default threw exception
java.lang.IllegalArgumentException: attempt to create saveOrUpdate event with null entity
at org.hibernate.event.SaveOrUpdateEvent.<init>(SaveOrUpdateEvent.java:40)
at org.hibernate.event.SaveOrUpdateEvent.<init>(SaveOrUpdateEvent.java:23)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:518)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:514)
at com.txsm.crm.dao.impl.DormNoticeDAO.addNotice(DormNoticeDAO.java:20)
at com.txsm.crm.service.impl.DormService.addNotice(DormService.java:22)
at com.txsm.crm.action.DormNoticeAction.addNotice(DormNoticeAction.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
public AbstractdormNoticeInfo getDormNoticeinfo() {
System.out.print("这里是否成功运行到????? get方法 ");
return dormNoticeinfo;
}
public void setDormNoticeinfo(AbstractdormNoticeInfo dormNoticeinfo) {
this.dormNoticeinfo = dormNoticeinfo;
System.out.print("这里是否成功运行到????? set方法");
}
信息: Server startup in 7167 ms
这里是否成功运行到????? get方法 这里是否成功运行到????? get方法 这里是否成功运行到????? get方法 这里是否成功运行到????? get方法 这里是否成功运行到????? get方法 这里是否成功运行到????? get方法 在action里的dormNotice=null
这里是否成功运行到????? get方法 sessionFactory=org.hibernate.impl.SessionFactoryImpl@106bde8
dormNotice=null
package com.txsm.crm.action;
public class DormNoticeAction extends ActionSupport {
protected AbstractdormNoticeInfo dormNoticeinfo;// 实体类
protected IDormService dormService;
public String execute() throws Exception {
return null;
}
public String addNotice() throws Exception { //添加公告
System.out.println("在action里的dormNotice="+this.getDormNoticeinfo());
dormService.addNotice(this.getDormNoticeinfo());
return SUCCESS;
}
public String deleteNotice() throws Exception { //删除公告
HttpServletRequest request=ServletActionContext.getRequest();
String strId=request.getParameter("id");
int id=Integer.parseInt(strId);
System.out.println("id="+id);
//dormNoticeinfo.setId(id);
//System.out.println("dormNoticeinfo="+dormNoticeinfo.toString());
//dormService.deleteNotice(dormNoticeinfo);
dormService.deleteNotice(id);
return SUCCESS;
}
public String preupdateNotice() throws Exception{ // 修改公告预处理
HttpServletRequest request=ServletActionContext.getRequest();
String strId=request.getParameter("id");
if(strId==null){
return ERROR;
}
else{
int id=Integer.parseInt(strId);
System.out.print("id="+id);
List list=new ArrayList();
list=dormService.selectNotice(id);
if(list.size()>0){
ActionContext act=ActionContext.getContext();
Map map=act.getSession();
map.put("updateNotice", list);
}
else return ERROR;
}
return "update";
}
public String updateNotice() throws Exception{
HttpServletRequest request=ServletActionContext.getRequest();
String strId=request.getParameter("id");
int id=0;
if(strId==null){
return ERROR;
}
else{
id=Integer.parseInt(strId);
}
dormNoticeinfo.setId(id);
dormService.updateNotice(dormNoticeinfo);
return SUCCESS;
}
public String selectNotice() throws Exception { //查询最新公告
List list=new ArrayList();
list=dormService.selectNotice(dormNoticeinfo);
if(list.size()>0){
ActionContext act=ActionContext.getContext();
Map map=act.getSession();
map.put("newNotice", list);
}
else{
return ERROR;
}
return "select";
}
//下面是get set方法
public AbstractdormNoticeInfo getDormNoticeinfo() {
return dormNoticeinfo;
}
public void setDormNoticeinfo(AbstractdormNoticeInfo dormNoticeinfo) {
this.dormNoticeinfo = dormNoticeinfo;
}
public IDormService getDormService() {
return dormService;
}
public void setDormService(IDormService dormService) {
this.dormService = dormService;
}
}
at com.txsm.crm.dao.impl.DormNoticeDAO.addNotice(DormNoticeDAO.java:20)
at com.txsm.crm.service.impl.DormService.addNotice(DormService.java:22)
at com.txsm.crm.action.DormNoticeAction.addNotice(DormNoticeAction.java:34)