JSP 页面中我做了这么一个 TABLE :<table border="1" cellpadding="3" cellspacing="3">
<tr>
<th>登录ID</th>
<th>用户密码</th>
<th>用户姓名</th>
</tr>
<c:forEach var="user" items="${sessionScope.ListUser}" >
<tr>
<td>${user.userId} </td>
<td>${user.passward} </td>
<td>${user.userName} </td>
<td>
<input type="button" value="编辑" onclick="javascript:window.open('editUserAction.do?userId=${user.userId}','','width=650,height=500,toolbar=no, status=no, menubar=no, resizable=yes, scrollbars=yes');">
</td>
**********************************************
我试图用“编辑”按钮触发的action editUserAction 对userId 为Table中的user.userId 数据项进行编辑,但是传参似乎不行??editUser.jsp页面内text中全都是空的,也就是没有传参成功。有人告诉我必须是form 才能传参,我不晓得talbe能不能???
<tr>
<th>登录ID</th>
<th>用户密码</th>
<th>用户姓名</th>
</tr>
<c:forEach var="user" items="${sessionScope.ListUser}" >
<tr>
<td>${user.userId} </td>
<td>${user.passward} </td>
<td>${user.userName} </td>
<td>
<input type="button" value="编辑" onclick="javascript:window.open('editUserAction.do?userId=${user.userId}','','width=650,height=500,toolbar=no, status=no, menubar=no, resizable=yes, scrollbars=yes');">
</td>
**********************************************
我试图用“编辑”按钮触发的action editUserAction 对userId 为Table中的user.userId 数据项进行编辑,但是传参似乎不行??editUser.jsp页面内text中全都是空的,也就是没有传参成功。有人告诉我必须是form 才能传参,我不晓得talbe能不能???
解决方案 »
- 图片存放在一台启动的tomcat下,另外一个tomcat应用中页面怎么使用
- 关于checkbox和multibox
- 64bit JDK 与 32bit JDK
- 关于页面中的打印按钮点击后ie地址栏中的地址显示与之前一致的实现问题
- 谁能帮我写个小脚本程序,谢谢了
- java打印,急,急!!!
- jsp怎样进行web发布啊??比如用iis??在线等~~~~~~~~~~~~~~~~~~~~~
- 急:使用jspsmart包上传附件,为什么总在upload方法中抛异常?
- JavaScrisp 里有没有什么函数可以判断我输入的文件是否存在?
- 怎样统计一个字段中符合条件的记录?
- image upload
- jsp的问题,高手们帮忙?
为什么不把编辑报称一个超链接形式的,直接用href连接到相应的Action
也可以用location.href
如果要用button的话,当onclick发生时,让它调用一个function了,你这样写层次很是不清,最好是写在一个javascript的function中
你页面没取得到值,那是你其它地方取值或者存值的问题
反正在ACTION应该取得到值
<a href="javascript:window.open('editSWYHAction.do?gddh=${swyh.gddh}','','width=650,height=500,toolbar=no, status=no, menubar=no, resizable=yes, scrollbars=yes');">编辑</a>
原来的页面也会做出动作,变成一个空页 有句" [object] "
**************************
回chenqi3166:在editAction 中我做了userId的取出工作,但似乎无效,代码部分如下
****************************************
public class EditSWYHAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request,HttpServletResponse response){
//声明操作数据库的类
int gddh = Integer.parseInt(request.getParameter("gddh").trim());
DBManager bm = new DBManager();
if (request.getParameter("gddh")!= null){
//从request对象中取得gddh的属性值
//SWYH对象
Swyh swyh =null;
//判断request中的action对象是否为null
if (request.getParameter("action")!=null){
//判断request中的action是否为updata
if ( request.getParameter("action").equals("updata")){
//创建SWYH对象
swyh = new Swyh();
//设置 xm 属性
swyh.setXm(request.getParameter("xm"));
swyh.setGddh(Integer.parseInt(request.getParameter("gddh").trim()));
swyh.setKhrq(request.getParameter("khrq"));
swyh.setDw(request.getParameter("dw"));
swyh.setFws(request.getParameter("fws"));
swyh.setSzd(request.getParameter("szd"));
swyh.setZz(request.getParameter("zz"));
///////////////////////////
boolean result = bm.updataSwyh(swyh);
//将结果保存到result中
request.setAttribute("result", result);
}
}else {
//如果操作不为updata就会从数据库中查询SWYH信息
swyh = bm.getSwyh(gddh);
}
//在request中设置Swyh 属性
request.setAttribute("Swyh", swyh);
}
return mapping.findForward("editSWYH");
}
}
在 DBManager 中getSwyh()如下:
public Swyh getSwyh(int gddh){
//通过Session 从数据库中取得SWYH 信息
Swyh swyh = (Swyh) session.load(Swyh.class,new Integer(gddh) );
//提交事务
transaction.commit();
return swyh;
}