public class AgentInfoAction extends DispatchAction {
/*
* Generated Methods
*/
AgentInfoManager agMager; public AgentInfoManager getAgMager() {
return agMager;
} public void setAgMager(AgentInfoManager agMager) {
this.agMager = agMager;
} /**
* Method execute
*
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward save(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
AgentInfoForm agf = (AgentInfoForm) form;
String id = request.getParameter("id");
TAgentinfo aginfo = null;
if(id==null){
id="";
}
if (id.equals("0")) {
id = "";
}
if (id.equals("")) {
aginfo = new TAgentinfo();
aginfo.setId(2000);
} else {
aginfo = agMager.getSingData(id);
}
aginfo.setAddrs(agf.getAddrs());
aginfo.setAgentname(agf.getAgentname());
aginfo.setCityname(agf.getCityname());
aginfo.setTel(agf.getTel());
agMager.add(aginfo);在这个地方总是报NullPointerException 其实aginfo这个对象中是有值的。
return list(mapping, form, request, response);
} public ActionForward list(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
List<TAgentinfo> aginfolist = agMager.getAllData();
request.setAttribute("aginfolist", aginfolist);
return mapping.findForward("aglist");
} public ActionForward delete(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String id = request.getParameter("id");
agMager.delete(id);
return list(mapping, form, request, response);
} public ActionForward edit(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
AgentInfoForm agf = (AgentInfoForm) form;// TODO
String id = request.getParameter("id");
TAgentinfo aginfo = agMager.getSingData(id);
agf.setAddrs(aginfo.getAddrs());
agf.setAgentname(aginfo.getAgentname());
agf.setCityname(aginfo.getCityname());
agf.setTel(aginfo.getTel());
agf.setId(aginfo.getId());
return new ActionForward("/form/ageInfo_add.jsp");
}
}
/*
* Generated Methods
*/
AgentInfoManager agMager; public AgentInfoManager getAgMager() {
return agMager;
} public void setAgMager(AgentInfoManager agMager) {
this.agMager = agMager;
} /**
* Method execute
*
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward save(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
AgentInfoForm agf = (AgentInfoForm) form;
String id = request.getParameter("id");
TAgentinfo aginfo = null;
if(id==null){
id="";
}
if (id.equals("0")) {
id = "";
}
if (id.equals("")) {
aginfo = new TAgentinfo();
aginfo.setId(2000);
} else {
aginfo = agMager.getSingData(id);
}
aginfo.setAddrs(agf.getAddrs());
aginfo.setAgentname(agf.getAgentname());
aginfo.setCityname(agf.getCityname());
aginfo.setTel(agf.getTel());
agMager.add(aginfo);在这个地方总是报NullPointerException 其实aginfo这个对象中是有值的。
return list(mapping, form, request, response);
} public ActionForward list(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
List<TAgentinfo> aginfolist = agMager.getAllData();
request.setAttribute("aginfolist", aginfolist);
return mapping.findForward("aglist");
} public ActionForward delete(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String id = request.getParameter("id");
agMager.delete(id);
return list(mapping, form, request, response);
} public ActionForward edit(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
AgentInfoForm agf = (AgentInfoForm) form;// TODO
String id = request.getParameter("id");
TAgentinfo aginfo = agMager.getSingData(id);
agf.setAddrs(aginfo.getAddrs());
agf.setAgentname(aginfo.getAgentname());
agf.setCityname(aginfo.getCityname());
agf.setTel(aginfo.getTel());
agf.setId(aginfo.getId());
return new ActionForward("/form/ageInfo_add.jsp");
}
}
解决方案 »
- 使用J2EE技术的工程硕士论文的有关问题
- 帮我看看我的LOG4J哪里错了,不能禁止hibernate输出
- Weblogic10.3上Cluster环境,MDB同时触发的问题。。
- 时间戳倒计时
- 项目部署在TOMCAT下的ROOT目录下的问题
- Spring中的控制器
- debug
- 怎样查看JSP编译的servlet文件(weblogic10.3)
- spring 的quartz动态分配时间
- 按j2ee Tutorial里的要求,j2ee到底如何配置?
- Could not parse configuration: /com/ccit/entca/conf/hibernate.cfg.xml 在线急等!!!
- 使用Lucene时的java.io.IOException: read past EOF问题
这个错误一般是由于什么没有实例化
aginfo.setAgentname(agf.getAgentname());
aginfo.setCityname(agf.getCityname());
aginfo.setTel(agf.getTel());
把这几个的值都打印一片看一些,有没有值
谢谢大家的指点