`
seadragonnj
  • 浏览: 57277 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论
阅读更多

关于cookie的一些知识:

  cookie是一种维护客户端状态的一种解决方案,

 cookie的概念:
       Cookie的格式实际上是一段纯文本信息, 由服务器随着网页一起发送到客户端, 并保存在客户端硬盘中指定的目录的. 大家都传说Cookie会造成严重的安全威胁什么的, 其实不是这么回事情. 服务器读取Cookie的时候, 只能够读取到这个服务器相关的信息. 而且, 浏览器一般只允许存放300个Cookie, 每个站点最多存放20个, 而且, 每个Cookie的大小现在在4K, 根本不会占用多少空间. 并且, Cookie是有时效性质的. 例如, 设置了Cookie的存活时间为1分钟, 则一分钟后这个Cookie就会被浏览器删除

可以通过javascript实现对cookie的的操作:

#
// 说明:用 Javascript 操作 Cookie
#
// 整理:http://www.CodeBit.cn
#
 
function getCookie( name ) {
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ';', len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}

 

function setCookie( name, value, expires, path, domain, secure ) {
var today = new Date();
today.setTime( today.getTime() );
if ( expires ) {
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );
document.cookie = name+'='+escape( value ) +
( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) + //expires.toGMTString()
( ( path ) ? ';path=' + path : '' ) +
( ( domain ) ? ';domain=' + domain : '' ) +
( ( secure ) ? ';secure' : '' );
}

 function deleteCookie( name, path, domain ) {
      if ( getCookie( name ) ) document.cookie = name + '=' +
         ( ( path ) ? ';path=' + path : '') +
         ( ( domain ) ? ';domain=' + domain : '' ) +
         ';expires=Thu, 01-Jan-1970 00:00:01 GMT';
} 

 在使用cookie时候,用户可能禁止了cookie,所以使用cookie之前可以检查一下cookie是否可用:

function CheckIfSupportCookie(){
SetCookie("test","test");
var test=GetCookie("test");
if(test!=null&&test=="test")
return true;
else
return false;

}

  在java中也可以对cookie进行操作,这里不写例子了,给出java操作cookie的一个方法 吧:

      String getComment() 返回cookie中注释,如果没有注释的话将返回空值.
      String getDomain() 返回cookie中Cookie适用的域名. 使用getDomain() 方法可以指示浏览器把Cookie返回给同一域内的其他服务器,而通常Cookie只返回给与发送它的服务器名字完全相同的服务器。注意域名必须以点开始
      int getMaxAge() 返回Cookie过期之前的最大时间,以秒计算。
      String getName() 返回Cookie的名字
      String getPath() 返回Cookie适用的路径。如果不指定路径,Cookie将返回给当前页面所在目录及其子目录下的所有页面。
      boolean getSecure() 如果浏览器通过安全协议发送cookies将返回true值,如果浏览器使用标准协议则返回false值。
      String getValue() 返回Cookie的值。笔者也将在后面详细介绍getValue/setValue。
      int getVersion() 返回Cookie所遵从的协议版本。
      void setComment(String purpose) 设置cookie中注释
      void setDomain(String pattern) 设置cookie中Cookie适用的域名
      void setMaxAge(int expiry) 以秒计算,设置Cookie过期时间。
      void setPath(String uri) 指定Cookie适用的路径。
      void setSecure(boolean flag) 指出浏览器使用的安 全协议,例如HTTPS或SSL。
      void setValue(String newValue ) cookie创建后设置一个新的值。
      void setVersion(int v) 设置Cookie所遵从的协议版本

 

关于not exists用法 (2009--5-21)

  select p1.productid from
   (select distinct productid from product_down_aplication t where t.userid=1081 and t.ifdeal=1 and t.deal_result =1 ) p1 where not exists
  ( select 1 from product_list pd where pd.userid =1081 and pd.status =3 and pd.productid = p1.productid)

 

简单理解就是not exists==not in exists==in

 

not exists 不存在,也就是说后面的括号中只要返回了数据那么这个条件就不存在了,可以理解为括号前的not

exists 是一个左表达式 ,括号后的查询是一个右表达式,只有当右表达式返回的也是not exists (即后面的查询出来的结果是非空的)时,等式才成立。

 http://www.iteye.com/topic/249786

 

有些日子没更新博客了!!!!

2009-06-04

1、在jquery中,它的ajax方式 中,在往后台传数据是,参数名不可以是status,这个应该是ajax作为关键字使用了:

$.post(url,{op:'ajax',orderCol:orderCol,
status:status,orderType:orderType,
'pageInfo.page':page},function(data){
})

2、在webwork中的配置文件中可以通过

<action name="commitEbook" class="com.upcenter.tools.ebook.action.EbookAction" method="commitEbook">
		   <result name="error" type="freemarker" >/common/error2.ftl</result>		
	       <result name="success" type="redirect-action">
			<param name="actionName">commitSuccess.action</param>
			<param name="namespace">/ebook</param>
			<param name="bookid">${model.bookid}</param>
			</result>
		</action>

 来跳转到新的url路径,可以通过

<param name="bookid">${model.bookid}</param>

 

这传参数,但这种方式传的参数好像是通过get方式的,它的参数都跟到url后面,感觉不太好,不过如果是要redirect到新的页面时,也没法通过post方式吧

2009-06-05

webwork的配置文件必须放到classpath目录下!!!,如果想放到别的地方可以修改的读取配置文件的类

分享到:
评论
2 楼 seadragonnj 2009-06-17  
谢谢,这段时间太忙了!
1 楼 wmj2003 2009-06-11  
别忘记写日志。小懒

相关推荐

Global site tag (gtag.js) - Google Analytics