我是做web的,在做的时候常常要定义变量
比如我上一个页面传过来一ID,我保存起来了?
第一:session排除不用,太浪费资源
第二:cookies要回发一次才可以,也不行,因为有时候我保存了就要用,这个时候就取不到
第三:protected这个类型的,页面一刷新就为null了?也不好
第四:protected static 怕以后用户之间参数串了?也不好高手们不知道你们都用什么样的类型保存参数的呀?(最好有session的速度有cookie的方便)---------这个是我自己想的

解决方案 »

  1.   

    session太浪费资源?我们原来的一个项目里面的变量差不多都是用session存的也没见资源怎么紧张啊?
      

  2.   

    fireForm.htm:点击“上传”按钮弹出内部窗口(showModalDialog),代码如下: 
    <html> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
    <title>无标题文档</title> 
    <script language="javascript"> 
    function onObjMore(url,name,height,width,formName) { 
     //window.alert(formName.file.type); 
     var feature = "dialogWidth:"+width+"px;dialogHeight:"+height+"px;scroll:yes;status:no;help:no;center:1"; 
     var returnTarget = window.showModalDialog(url, name, feature); 
     if(returnTarget != undefined && returnTarget.length > 1) { 
      //document.location = returnTarget; 
      formName.file.value=returnTarget; 
     } 
     return false; 

    </script> 
    <link href="css/aljoin.css" rel="stylesheet" type="text/css"> 
    </head> <body> 
    <form name="proForm" method="post" action=""> 
      <table width="400" border="0" cellpadding="0" cellspacing="0"> 
        <tr> 
          <td width="93" height="25" style="white-space:nowrap " nowrap>文件</td> 
          <td width="307" height="25"><input name="file" type="text" id="file"></td> 
        </tr> 
        <tr> 
          <td height="25"> </td> 
          <td height="25"><input type="button" name="Submit" value="上传文件" onClick="onObjMore('upfile.htm','upfile',300,300,proForm)"></td> 
        </tr> 
      </table> 
    </form> 
    </body> 
    </html> 
    upfile.htm:点击”关闭”按钮返回window.returnValue值给opener,代码如下: 
    <html> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
    <title>无标题文档</title> 
    <script language="javascript"> 
    function exit() { 
    window.returnValue = "images/upload/2004080512.jpg"; 
    window.close(); 

    </script> 
    </head> 
    <body> 
    <input name="" type="button" value="关闭窗口" onClick="exit()"> 
    </body> 
    </html> 
      

  3.   

    如果只在一个页面里,可以用viewstate
      

  4.   

    to:leonbingo(libin) ( ) 信誉:100 一般定义的变量也就是在这个页面中会使用
    如果多个页面使用我会保存cookies的那viewstate的资源大不?
      

  5.   

    viewstate
    session
    都可以
    不会太占资源的
      

  6.   

    我现在是用viewstate的,
    我想不出来用什么好了?
    只好用这个了?谢谢大家