传递不到servlet?action=xxx的问题

提交以后传递不到后面的action,是因为form表单里面没有设置method="post"

<body>
   <form>
		<table>
			<tr>
				<th>工号</th>
				<th>姓名</th>
				<th>密码</th>
				<th>状态</th>
				<th>电话</th>
				<th>身份证</th>
				<th>余额</th>
				<th>性别</th>
			</tr>
			<c:forEach var="c" items="${list}">
			<tr>
				<td>${c.worknum}</td>
		   		<td>${c.repairtorname}</td>
		   		<td>${c.repairtorpassword}</td>
		   		<td>${c.statues}</td>
		   		<td>${c.phonenum}</td>
		   		<td>${c.idcard}</td>
		   		<td>${c.balance}</td>
		   		<td>${c.gender}</td>
		   		<td><a href="repairtorsevlet?op=toupdate&id=${c.id}">修改</a></td>
		   		<td><a href="javascript:deleterepairtor(${c.id},'${c.repairtorname}')">删除</a></td>
		   		<td><input type="checkbox" name="ids" value="${c.id}">
			</tr>
			 </c:forEach>
		</table>
		<input type="button" onclick="window.location='addrepairtor.jsp'" value="添加">
		<input type="button" onclick="deletes()" value="批量删除">
	</form>
	
	<script type="text/javascript">
		function deleterepairtor(id,repairtorname){
			if(confirm('确定删除'+repairtorname)){
				window.location = 'repairtorsevlet?op=delete&id='+id;
			}
		}
		
		function deletes(){
			if(confirm('确定删除')){
				var f = document.forms[0];
				f.action = 'repairtorsevlet?op=deletes';
				f.submit();
			}
		}
	</script>
  </body>

添加method="post",问题解决

<body>
   <form method="post">
		<table>
			<tr>
				<th>工号</th>
				<th>姓名</th>
				<th>密码</th>
				<th>状态</th>
				<th>电话</th>
				<th>身份证</th>
				<th>余额</th>
				<th>性别</th>
			</tr>
			<c:forEach var="c" items="${list}">
			<tr>
				<td>${c.worknum}</td>
		   		<td>${c.repairtorname}</td>
		   		<td>${c.repairtorpassword}</td>
		   		<td>${c.statues}</td>
		   		<td>${c.phonenum}</td>
		   		<td>${c.idcard}</td>
		   		<td>${c.balance}</td>
		   		<td>${c.gender}</td>
		   		<td><a href="repairtorsevlet?op=toupdate&id=${c.id}">修改</a></td>
		   		<td><a href="javascript:deleterepairtor(${c.id},'${c.repairtorname}')">删除</a></td>
		   		<td><input type="checkbox" name="ids" value="${c.id}">
			</tr>
			 </c:forEach>
		</table>
		<input type="button" onclick="window.location='addrepairtor.jsp'" value="添加">
		<input type="button" onclick="deletes()" value="批量删除">
	</form>
	
	<script type="text/javascript">
		function deleterepairtor(id,repairtorname){
			if(confirm('确定删除'+repairtorname)){
				window.location = 'repairtorsevlet?op=delete&id='+id;
			}
		}
		
		function deletes(){
			if(confirm('确定删除')){
				var f = document.forms[0];
				f.action = 'repairtorsevlet?op=deletes';
				f.submit();
			}
		}
	</script>
  </body>

猜你喜欢

转载自blog.csdn.net/Milan__Kundera/article/details/81671093