Form中接受不到数据

aboutF 2012-02-21 10:24:00
JSP源码如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" contentType="text/html; charset=GBK"%>
<%@ taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/tld/struts-logic.tld" prefix="logic"%>

<html>

<head>

<title>
员工查询
</title>
<style type="text/css">
body {
margin-top: 8px;
background-image: url(../images/bg2.jpg);
}

</style>

<link href="./css/new_edit.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript" src="./js/app.edit.js"></script>
<script language="javascript" type="text/javascript" src="./js/app.uservalidate.js"></script>
</head>

<body>
<html:form action="/operationAgentAction" method="post">
<input type="hidden" name="method" value="showOperation"/>
<html:hidden property="comId"/>
<table width="765" border="0" cellspacing="2" cellpadding="1" class="table_default">
<tr>
<td height="17" colspan="4"></td>
</tr>
<tr>
<th width="15%" height="17" ><div align="center">业务员姓名</div></th>
<td width="15%">
<html:text property="agentname" styleClass="inputblue" style="width:120px" />
</td>
<th width="15%" height="17" ><div align="center">所属机构</div></th>
<td width="20%">
<html:text property="comname" readonly='true' styleClass="inputblue" style="width:120px" onclick="openBrWindow('operationAgentAction.do?method=departmentTreeList','选择机构','260','400');" />
</td>
</tr>
<tr>
<td colspan="4" align="right">
<input type="button" name="selectall" class="btn002" value="新增" onclick="openBrWindow('operationAgentAction.do?method=loadAddOperationAgent','新增业务员','730','300');" />
    
<input type="button" name="selectall" class="btn002" value="删除" onclick="onDelete()" />
    
<input type="button" name="btnCon" class="btn002" value="查询" onclick="Search()" />
    
<input type="button" name="btnCon" class="btn002" value="重置" onclick="resetVal()" />
</td>
</tr>
</table>
<br/>
<logic:present name="PAGE">
<table width="98%" border="1" cellspacing="1" cellpadding="0" class="grid_default grid_blue" align="center">
<thead>
<tr>
<td width="3%" nowrap="true">
<input type="checkbox" name="checkbox" onclick="checkAll(this.form.agentcodes,this.checked)" />
</td>
<td height="23" width="60px">
<div align="center">
编号
</div>
</td>
<td height="23" width="60">
<div align="center">
姓名
</div>
</td>
<td height="23" width="30px">
<div align="center">
性别
</div>
</td>
<td width="">
<div align="center" nowrap>
固定电话
</div>

</td>
<td width="">
<div align="center" nowrap>
手机号码
</div>

</td>
<td width="">
<div align="center" nowrap>
所属机构
</div>

</td>
<td width="">
<div align="center" nowrap>
修改
</div>
</td>
<td width="">
<div align="center" nowrap>
查看
</div>
</td>

</tr>
</thead>
<logic:notEmpty name="PAGE">
<%boolean b=false;%>
<logic:iterate name="PAGE" property="dataList" id="fun" indexId="ind">
<tr class='<%=((b=!b)?"":"fuscous")%>'>
<td height="20">
<input type="checkbox" name="agentcodes" value='<bean:write name="fun" property="agentcode"/>' />
</td>
<td height="20" align="center">
<bean:write name="fun" property="agentcode" />
</td>
<td height="20" width="" align="center">
<bean:write name="fun" property="agentname" />
</td>
<td height="20" width="" align="center" style="word-break:break-all">
<logic:equal name="fun" property="sex" value="0">

</logic:equal>
<logic:equal name="fun" property="sex" value="1">

</logic:equal>
</td>
<td height="20" width="" align="center" style="word-break:break-all">
<bean:write name="fun" property="shortNum" />
</td>
<td height="20" width="" align="center" style="word-break:break-all">
<bean:write name="fun" property="phone" />
</td>
<td height="20" width="" align="center" style="word-break:break-all">
<bean:write name="fun" property="mobile" />
</td>
<td height="20" width="" align="left" style="word-break:break-all">
  <bean:write name="fun" property="comname" />
</td>
<td align="center" onclick="openBrWindow('operationAgentAction.do?method=loadAddOperationAgent&agentcode=<bean:write name="fun" property="agentcode"/>&operating=edit','修改工单','730','300')">
<div align="center">
<img src="./images/icon-xiugai.gif" width="16" height="16" alt="" style="CURSOR: hand"/>
</div>
</td>
<td align="center" onclick="openBrWindow('operationAgentAction.do?method=viewOperationAgent&agentcode=<bean:write name="fun" property="agentcode"/>','查看工单','730','300')">
<div align="center">
<img src="./images/icon-liulan.gif" width="16" height="16" alt="" style="CURSOR: hand"/>
</div>
</td>
</tr>
</logic:iterate>
</logic:notEmpty>
</table>
</logic:present>
</html:form>



<logic:present name="PAGE">
<logic:notEmpty name="PAGE">
<table>
<tr height="20">
<td>
<bean:write name="PAGE" property="navigatorBar" filter="false" />
</td>
</tr>
</table>

</logic:notEmpty>
</logic:present>
</body>
</html>


<script language="javascript" type="text/javascript">

//查询业务员信息
function Search(){
document.forms[0].submit();
}

//查询业务员信息
function resetVal(){
document.forms[0].agentname.value="";
document.forms[0].comId.value="";
document.forms[0].comname.value="";
}

//删除当前数据
function onDelete() {

var agentcodes;

var checkBox = document.getElementsByName("agentcodes");
for ( var i = 0; i < checkBox.length; i++) {
if (checkBox[i].checked) {
agentcodes += "&&##&&"+checkBox[i].value;
}
}

if (agentcodes == null || agentcodes == undefined ) {
alert("请选择要删除的员工信息");
return;
}
if (!confirm("确认删除选中的员工信息吗?")) {
return;
}

operationAgentForm.method.value="delOperationAgent";

operationAgentForm.submit();
return;
}
</script>
在调用删除方法时跟踪到Action中的delOperationAgent方法之后发现form中没有数据

OperationAgentForm operationAgentForm = (OperationAgentForm) form;

String[] agentCodes = operationAgentForm.getDelAgentCodes().split("&&##&&"); //该行报空指针
String delMessage = this.operationAgentService.delOperationAgentEntity(agentCodes);


高手帮忙看看问题出在哪里。谢谢。
...全文
81 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
znnevergiveup 2012-02-21
  • 打赏
  • 举报
回复
get() set()了没有?
wenjie4892543 2012-02-21
  • 打赏
  • 举报
回复
OperationAgentForm operationAgentForm = (OperationAgentForm) form;
好像是s1 的写法吧!!

String[] agentCodes = operationAgentForm.getDelAgentCodes().split("&&##&&"); //该行报空指针

这样不行 就换个方法取值!!
安特矮油 2012-02-21
  • 打赏
  • 举报
回复
用的struts1?如果是那么struts的配置文件里面是否有这样的东西?

<form-bean name="TaskForm" type="com.cs.web.form.TaskForm"></form-bean>

<action path="/replaceFile" type="org.springframework.web.struts.DelegatingActionProxy" validate="false" name="TaskForm">
<forward name="SUCCESS" path="/upload.jsp"></forward>
</action>

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧