1.Struts下面Vector居然不在bean 的属性认识范畴,而String[]可行!
2.页面刷新的时候,可以在<HEAD>处设置no-cache,完成了页面的刷新任务,但是耗费资源了。
<%@ page contentType="text/html; charset=gb2312" language="java"
import="java.sql.*" errorPage=""%>
<%@ page import="com.telecom.common.form.DepForm"%>
<%@ page import="java.sql.Connection"%>
<%@ page import="java.sql.ResultSet"%>
<%@ page import="java.sql.Statement"%>
<%@ page import="java.util.Vector"%>
<%@ page import="com.telecom.dao.DBLinker"%>
<%@ page import="com.telecom.common.form.EnterpriseNumForm"%>
<%
EnterpriseNumForm enf = new EnterpriseNumForm();
Connection conn = null;
ResultSet rs = null;
ResultSet rs2 = null;
Statement sta = null;
Statement sta2 = null;
try {
conn = (Connection) DBLinker.linkDB();
String sql1 = "select distinct(strEnID) eid from tbEnterpriseNum";
rs = null;
sta = conn.createStatement();
rs = sta.executeQuery(sql1);
if (rs.next()) {
enf.setEnID(rs.getString("eid"));
}else{
enf.setEnID("0000");
}
String sql2 = "select distinct(strPresentNum) pn from tbEnterpriseNum ";
rs2 = null;
sta2 = conn.createStatement();
rs2 = sta2.executeQuery(sql2);
Vector v = new Vector();
while (rs2.next()) {
v.add(rs2.getString("PN"));
}
String[] s=new String[v.size()];
for(int i=0;i<v.size();i++){
s[i]=v.elementAt(i).toString();
}
enf.setNums(s);
System.out.println(v.size());
//session.setAttribute("enf",enf);
} catch (Exception e) {
} finally {
rs2.close();
rs.close();
sta.close();
sta2.close();
conn.close();
}
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="../include/style.css">
<title>详细信息</title>
<script language="javascript">
function checkNum(){
selectAllMember(form1.nums);
form1.submit();
}
function selectAllMember(selection)
{
var ops=selection.options;
for(var i=0;i<ops.length;i++)
{
ops[i].selected=true;
}
}
function deleteSelectedMember(selection)
{
var ops=selection.options;
for(var i=0;i<ops.length;i++)
{
if(ops[i].selected==true)
{
selection.remove(i);
i--;
}
}
}
function other_add(){
if(form1.otherNum.value==""){
alert("不能为空");
}else{
additemNoRepeat(form1.otherNum.value,form1.otherNum.value,form1.nums);
}
}
function additemNoRepeat(Otext,Ovalue,selectElement){//不重复的添加
for(j=0;j<selectElement.options.length;j++){
if(selectElement.options[j].value==Ovalue){
var flag=1;
alert(Otext+"已添加");
break;
}
}
if(flag!=1){
selectElement.options[selectElement.options.length]=new Option(Otext,Ovalue);
}
}
</script>
<style type="text/css">
<!--
.style3 {FONT-WEIGHT: bold; FONT-SIZE: 14px; COLOR: #246bad; LINE-HEIGHT: 2 }
body {
background-color: #E7F0FA;
}
-->
</style>
<meta http-equiv="pragma" content="no-cache">
<%response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
response.addHeader("Expires","Thu, 01 Jan 1970 00:00:01 GMT");
response.flushBuffer();%>
</head>
<body opener.location.reload()">
<table width="100%">
<tr>
<td bgcolor="#ffffff">
<table width="530" border="0" cellpadding="0" cellspacing="0"
style="word-break:break-all; ">
<tr>
<td width="60" background="../linkman/images/s22.jpg">
</td>
<td width="447" background="../linkman/images/s23.jpg">
<span class="style3">修改企业号码和主叫绑定号码</span>
</td>
<td width="6">
<img src="../linkman/images/s24.jpg" width="6" height="58">
</td>
<td width="17"></td>
</tr>
<tr>
<td colspan="4">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="17">
</td>
<td bgcolor="#e7f0fa">
<table width="94%" border="0" align="center" cellpadding="0"
cellspacing="0">
<form name="form1" method="post"
action="../companyadmin/EditENF.do?method=SaveENF" >
<tr>
<td width="17%" height="25">
企业号码:
</td>
<td width="100%" height="25">
<input name="enID" type="text" id="enID"
value="<%=enf.getEnID()%>">
</td>
</tr>
<tr>
<td width="17%" height="25">
主叫绑定号码:
</td>
<td>
<select name="nums" size="20" multiple id="nums"
style="width:64%">
<%
String[] v = enf.getNums();
System.out.println(v.length);
if (v.length != 0) {
for (int k = 0; k < v.length; k++) {
String oldpn = new String();
oldpn = v[k];
System.out.println(oldpn);
%>
<option value="<%=oldpn%>">
<%=oldpn%>
</option>
<%
}
}
%>
</select>
<input type="button" name="Submit" value="删除号码"
onClick="deleteSelectedMember(document.all.nums)">
</td>
</tr>
<tr>
<td height="30" scope="col">
请输入号码:
</td>
<td>
<input type="text" id="otherNum">
<input type="button" name="Submit" value="添加"
onClick="other_add()">
</td>
</tr>
</form>
</table>
</td>
<td width="17">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="30" colspan="4">
<div align="center">
<a href="javascript:checkNum();">保存设置</a>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>