在配置里面 再加一句
<result name="input">错误页面</result>
<result name="input">错误页面</result>
解决方案 »
- hibernate总说映射不上怎么回事呢
- struts+spring时,关于singleton使用的讨论
- webwork+spring+hibernate用myeclipse如何搭建!急,谢谢了!
- 如何通过URLConnection获取下载的资源的名称
- 请教关于wsdl2java 的问题
- 怎样将Tomcat打进服务里面?
- 请给我一点websphere的资料和一个使用websphere的例子
- 请问有关servlet调用ejb的问题
- 马年终极一问 java过滤器的疑惑
- 关于使用JDBC的批量操作插入ORACLE数据库数据丢失的问题
- 没办法了,谁教下我的SSH框架配置文件如何加连接池??
- 如何在servlet的dopost方法中弹出个对话框?
至于后台的NumberFormatException 错误应该能定位到哪一行吧
是因为你的页面上传过来的userIds 数组 里面的值不能转为long类型 不全部都是数字
加了一样的 页面传过来的 就是一个userId 是STRING类型的 我转换了
String[] userIds = request.getParameterValues("userId");
for(int i = 0 ; i < userIds.length ; i++) {
//long userId = new Long(userIds[i]).longValue();
userId=Long.parseLong(userIds[i]);
System.out.println("asasasasas======="+userId);
userDao.removeAll(userId);
}
return SUCCESS;
}
我现在把那个判断去掉了 直接获取传过来的参数
在String[] userIds = request.getParameterValues("userId"); 设置的断点 没反应
当传的是1个userId的时候程序正常执行
public String deleteUser(){
String[] userIds = request.getParameterValues("userId");
if(null == userIds || userIds.length() == 0) {
msg = "请选择要删除的用户!";
return ERROR;
}for(int i = 0 ; i < userIds.length ; i++) {
long userId=Long.parseLong(userIds[i]);
System.out.println("asasasasas======="+userId);
userDao.removeAll(userId);
}return SUCCESS;
}
这样就行了
request.getParameter("userId")这句在有2个checkbox的时候有毛病
msg = "请选择要删除的用户!";
return ERROR;
}else {String[] userIds = request.getParameterValues("userId");
for(int i = 0 ; i < userIds.length ; i++) {
//long userId = new Long(userIds[i]).longValue();
long userId=Long.parseLong(userIds[i]);
System.out.println("asasasasas======="+userId);
userDao.removeAll(userId);
}return SUCCESS;
}
}
就2个页面 一个正确的 一个错误的 从前台页面获取一个userId 转换成long型 就这样的
msg = "请选择要删除的用户!";
return ERROR;
}else {
String[] userIds = request.getParameterValues("userId");
for(int i = 0 ; i < userIds.length ; i++) {
long userId=Long.parseLong(userIds[i]);
System.out.println("asasasasas======="+userId);
userDao.removeAll(userId);
}return SUCCESS;
}
}上面的加颜色失败了
request.getParameter("userId") 是null 所以报了 转换格式出错 ???
struts2中这句根本就是多余的!只要的name和你action中的变量名是一样的,即get对应的上。
即你直接可在你的ACTION中定义String[] userId;即可自动获取到复选框中所有选中的value。
就是我这个主题帖的错误啊 一模一样的 单个userId是没问题的 为什么多个就出问题