<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'list.jsp' starting page</title> <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"> </head>
<body><s:iterator value="#request.cpList" id="cp" > <li><s:property value="#cp.name" /> </li>
<li><s:property value="#cp.title" /> </li>
<li><s:property value="#cp.info" /> </li>
<li><a href="cpdel?entity.id=%{#cp.id}">删除 </a></li>
<li><a href="cpUpdate?entity.id=%{#cp.id}">修改</a></li>
</s:iterator>
</body>
package com.pro.action;import java.util.List;import com.pro.entity.Cpinfo;
import com.pro.serivce.CpinfoSerivce;public class CpinfoAction { private static final long serialVersionUID = 1L; private CpinfoSerivce serivce;
private Cpinfo entity;
public String cpdel() throws Exception { System.out.println(entity.getId());
serivce.delete(entity);
return "rs";}
public CpinfoSerivce getSerivce() {
return serivce;
}public void setSerivce(CpinfoSerivce serivce) {
this.serivce = serivce;
}@SuppressWarnings("unchecked")
public void setCpList(List cpList) {
this.cpList = cpList;
}public void setEntity(Cpinfo entity) {
this.entity = entity;
}
}
java.lang.NullPointerException
com.pro.action.CpinfoAction.cpdel(CpinfoAction.java:33)System.out.println(entity.getId());
这就是33行
估计是得不到值,忘指点有更好的做法也介绍介绍
<%@ taglib prefix="s" uri="/struts-tags"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'list.jsp' starting page</title> <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"> </head>
<body><s:iterator value="#request.cpList" id="cp" > <li><s:property value="#cp.name" /> </li>
<li><s:property value="#cp.title" /> </li>
<li><s:property value="#cp.info" /> </li>
<li><a href="cpdel?entity.id=%{#cp.id}">删除 </a></li>
<li><a href="cpUpdate?entity.id=%{#cp.id}">修改</a></li>
</s:iterator>
</body>
package com.pro.action;import java.util.List;import com.pro.entity.Cpinfo;
import com.pro.serivce.CpinfoSerivce;public class CpinfoAction { private static final long serialVersionUID = 1L; private CpinfoSerivce serivce;
private Cpinfo entity;
public String cpdel() throws Exception { System.out.println(entity.getId());
serivce.delete(entity);
return "rs";}
public CpinfoSerivce getSerivce() {
return serivce;
}public void setSerivce(CpinfoSerivce serivce) {
this.serivce = serivce;
}@SuppressWarnings("unchecked")
public void setCpList(List cpList) {
this.cpList = cpList;
}public void setEntity(Cpinfo entity) {
this.entity = entity;
}
}
java.lang.NullPointerException
com.pro.action.CpinfoAction.cpdel(CpinfoAction.java:33)System.out.println(entity.getId());
这就是33行
估计是得不到值,忘指点有更好的做法也介绍介绍
解决方案 »
- 如何将项目部署到JBOSS下面
- (网页制作)有谁知道怎样在网页上播放各种格式的视频文件?希望有实例代码(例如:rmvb)
- 用jsp实现用户登录界面 但点击“登录”后页面空白
- java中,我想每秒钟加一次,用哪个函数啊
- 我的框架页面为什么不能显示?难道框架页面不能连接jsp文件?
- 给分问题!
- JDBC直接访问SQL SERVER报下面的错误,请问怎么解决?
- 急! 初学者碰到的一个小问题!
- 我在表单里面用了下拉列表,我怎么在处理表单的程序中取得下拉列表选择的内容
- 关于在weblogic中配置servlet?
- Cannot retrieve definition for form bean null on action /savePlanB
- 各位帮我看看吧,我快哭了,运行就出错,什么意思嘛
entity的get方法呢,加上get方法试试看
public void setEntity(Cpinfo entity) {
this.entity = entity;
}
最后一段代码就是set 有get的
改成:
<li><a href="cpdel?entity.id=<s:property value="#cp.id" />">删除 </a></li>try it...
System.out.println(entity.getId().toString());
return "rs";
}
java.lang.NullPointerException
com.pro.action.CpinfoAction.cpdel(CpinfoAction.java:33)写成这样都错标准的无法取得值我这里其实有个疑问的
<a href="cpUpdate?entity.id=%{#cp.id}">
是写 实体类类名 还是 Action里为 实体类 取的属性名
就是那个entity
相应的修改的功能也是类似的