jsp 复选框使用方法

发布时间:2022-04-17 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了jsp 复选框使用方法脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
1,页面上
复制代码 代码如下:

<td width="4%" height="26" align="center">
<input tyPE="checkbox" name="checkbox"
value=<%=user.getId()%> />
</td>


2.action
复制代码 代码如下:

String[] checkbox = request.getParameterValues("checkbox");
List<Integer> checkboxs = new ArrayList<Integer>();
int operatorId =SessionMgr.getAccountSession(request, response).getId();
LOGger.debug("--operatorId--:"+operatorId);
//判断复选框是否有选
if(checkbox!=null&&!"".equals(checkbox)){
for(int i=0;i<checkbox.length;i++){
//checkboxs.add(checkbox[i]);
String id_str = checkbox[i];
int id = Integer.parseInt(id_str);
//判断是否是自己本身
if(id==operatorId){
message="不能删除自己的用户";
}
//判断是否是admin超级管理员
if(id==1){
message="admin用户不能删除";
}
//判断该用户是否存在工单
boolean isExist= false;
isExist = UserMgr.isExistWorkbillOfuser(id);
logger.debug("--isExist--:"+isExist);
if(isExist){
message = "该用户有建工单不能删除";
}
if(id!=operatorId&amp;&id!=1&&!isExist){
checkboxs.add(id);
}
}
try{
UserMgr.deleteUser(checkboxs);
message = "删除成功!";
}catch(SystemException se){
logger.error(se);
}
}
else{
message = "您还没选择用户!";
}

脚本宝典总结

以上是脚本宝典为你收集整理的jsp 复选框使用方法全部内容,希望文章能够帮你解决jsp 复选框使用方法所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签:jsp