刷新的时候,总遇到这个问题,就写了段代码,以后可以作成taglib封一下,反正是个常用的功能
<% //把上次提交的信息存成Hidden,做一个form,在reload的时候用submit
StringBuffer sb = new StringBuffer();
Map map = request.getParameterMap();
Set keySet = map.keySet();
sb.append("<form method = 'post' name='reloadForm' >");
for (Iterator iter = keySet.iterator(); iter.hasNext();) {
String key = (String) iter.next();
String[] values = (String[])map.get(key);
for(int j=0;j<values.length;j++){
sb.append("<input type='hidden' name='"+key+"' value='"+values[j]+"'/>");
}
}
sb.append("</form >");
out.println(sb.toString());
%>
<script>
document.location.reload= function(){
document.reloadForm.submit();
}
</script>