解决办法:
HTML部件value=""要加双引号
value="成败 呒呒.txt"
代码1:
MyHtml.html
-----------------------------------------------------------------------------------------------------
<html>
<script language = javascript type="text/javascript">
function submitBatch(form,func){
var action = func + "";
var countFid = getCheckedCount(form.elements["fid"]);
alert ("countFid = "+countFid);
form.action = action;
form.submit();
return true;
}
//调用的函数1 getCheckedCount(control)
function getCheckedCount(control) {
var count = 0;
if (control) {
if (control.length) {
for (var i=0; i<control.length; i++) {
var c = control[i];
if (c.checked) count ++;
}
} else {
var c = control;
if (c.checked) count ++;
}
}
return count;
}
//调用的函数2 resConfirmDelete(fileCount, folderCount)
function resConfirmDelete(fileCount, folderCount) {
return confirm("你确定要删除选定的 "
+ folderCount + " 项吗?")
}
</script>
<body>
<form action="" method="post" >
<input name="test_name" type="text" value="zhaozb" />zhaozb<br>
<input name="fid" type="checkbox" value= zhao zb />zhao zb<br>
<input name="fid" type="checkbox" value=小 兵 />小 兵<br>
<input name="fid" type="checkbox" value="zhaozb3" />zhaozb3<br>
<input name="submitTest" type="text" onClick="submitBatch(form,'MyJsp.jsp');" value="提交">
</form>
</body>
</html>
------------------------------------------------------------------------------------------------------
代码2:
MyJsp.jsp
------------------------------------------------------------------------------------------------------
<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<html>
<head>
<title>test</title>
</head>
<body>
看看能不能接受到. <br>
<%
request.setCharacterEncoding("gb2312");
String str="ok";
str = request.getParameter("test_name");
String items[]=request.getParameterValues("fid");
for(int i=0;i<items.length;i++){
str = items[i];
out.println(i+" = "+str+"<br>");
}
//out.println("items="+items.length);
//out.print(str+"ss");
%>
</body>
</html>
------------------------------------------------------------------------------------------------------