<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 22, comments - 32, trackbacks - 0, articles - 73
      BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

     

    Hiberante3 一級(jí)緩存總結(jié)

    1.             Session 級(jí)別的緩存,它同session邦定。它的生命周期和session相同。Session消毀,它也同時(shí)消毀;管理一級(jí)緩存,一級(jí)緩存無法取消,用兩個(gè)方法管理,clear(),evict()

    2.             兩個(gè)session 不能共享一級(jí)緩存,因它會(huì)伴隨session的生命周期的創(chuàng)建和消毀;

    3.             Session緩存是實(shí)體級(jí)別的緩存,就是只有在查詢對(duì)象級(jí)別的時(shí)候才使用,如果

    使用HQLSQL是查詢屬性級(jí)別的,是不使用一級(jí)緩存的!切記!!!!

    4 .  iterate 查詢使用緩存,會(huì)發(fā)出查詢IdSQLHQL語句,但不會(huì)發(fā)出查實(shí)體的,

    它查詢完會(huì)把相應(yīng)的實(shí)體放到緩存里邊,一些實(shí)體查詢?nèi)绻彺胬镞呌校蛷木彺嬷胁樵儯€是會(huì)發(fā)出查詢idSQLHQL語句。如果緩存中沒有它會(huì)數(shù)據(jù)庫中查詢,然后將查詢到的實(shí)體一個(gè)一個(gè)放到緩存中去,所以會(huì)有N+1問題出現(xiàn)。

    5 . List()iterate 查詢區(qū)別:

    使用iterate,list查詢實(shí)體對(duì)象*N+1問題,在默認(rèn)情況下,使用query.iterate查詢,有可以能出現(xiàn)N+1問題

    所謂的N+1是在查詢的時(shí)候發(fā)出了N+1sql語句1:首先發(fā)出一條查詢對(duì)象id列表的sqlN:

    根據(jù)id列表到緩存中查詢,如果緩存中不存在與之匹配的數(shù)據(jù),那么會(huì)根據(jù)id發(fā)出相應(yīng)的sql語句listiterate的區(qū)別?

    list每次都會(huì)發(fā)出sql語句,list會(huì)向緩存中放入數(shù)據(jù),而不利用緩存中的數(shù)據(jù)

    iterate:在默認(rèn)情況下iterate利用緩存數(shù)據(jù),但如果緩存中不存在數(shù)據(jù)有可以能出現(xiàn)N+1問題

    6Get()load(),iterate方法都會(huì)使用一級(jí)緩存,

     

    7.hiberate3 session 存儲(chǔ)過程如下:

           例如 object 對(duì)象

           Session.save(object);

           這時(shí)候不會(huì)把數(shù)據(jù)放到數(shù)據(jù)庫,會(huì)先放到session緩存中去,數(shù)據(jù)庫中沒有相應(yīng)記錄,session.flush();才發(fā)SQLHQL語句,數(shù)據(jù)庫中有了相應(yīng)記錄,

           但是數(shù)據(jù)庫用select查不到,這是跟數(shù)據(jù)庫事物級(jí)別有關(guān)系,(這里在說下數(shù)據(jù)庫的事務(wù)隔離級(jí)別一共四種如下:)
        數(shù)據(jù)庫隔離級(jí)別:
            隔離級(jí)別                       是否存在臟讀  是否存在不可重復(fù)讀     是否存在幻讀;
        Read UnCommited(未提交讀)               Y            Y                     Y
        Read Commited (提交讀 oraclel默認(rèn))      N            Y                     Y
        Repeatable Read(不可重復(fù)讀(Msql默認(rèn)))  N            N                     Y 
        Serializable(使用很少)                  N            N                     N

        


           Session.beginTrransaction().commit();

           事物提交后可以查詢到了。

    Session.flush()語句但是為什么不寫呢,因?yàn)?/span>commit()會(huì)默認(rèn)調(diào)用flush();


    Hiberante3 二級(jí)緩存總結(jié)

    1.Hibernate3的(sessionFactory)二級(jí)緩存和session級(jí)別的緩存一樣都只對(duì)實(shí)體對(duì)象做緩存,不對(duì)屬性級(jí)別的查詢做緩存;二級(jí)緩存的生命周期和sessionFactory的生命周期是一樣的,sessionFactory可以管理二級(jí)緩存;

    2.sessionFactory級(jí)別的緩存,需要手動(dòng)配置;所有的session可以共享sessionFactory 級(jí)別的緩存;(一般把一些不經(jīng)常變化的實(shí)體對(duì)象放到sessionFactory級(jí)別的緩存中,適合放不經(jīng)常變化的實(shí)體對(duì)象。)

    3.Hiberante3二級(jí)緩存的配置和使用方法如下:

    1. 必須把ehcache.jar包導(dǎo)入,然后到Hibernate3.2etc文件下把ehcache.xml復(fù)制到工程src目錄下(ehcache.xml里邊的參數(shù)里邊有詳細(xì)英文說明);

    (說明:ehcache.jar是第三方法的緩存產(chǎn)品,hiberante只是把它做了集成,還有好多第三方hibernate集成的緩存產(chǎn)品,相關(guān)說明請(qǐng)查閱hiberante3開發(fā)手冊(cè);ehcache支持分布應(yīng)用的(這個(gè)和Hibernate3.2開發(fā)手冊(cè)有出入,經(jīng)過官網(wǎng)查證確實(shí)支持了),如果有分布式需求,請(qǐng)換成支持分布式的二級(jí)緩存產(chǎn)品,hiberate3開發(fā)手冊(cè)都有相頭說明。配置方法都類似);

    4.Hibernate3的二級(jí)緩存默認(rèn)是開起的,也可以指定開起。在hibernate.cfg.xml 文件下配置如下:

    *修改hibernate.cfg.xml文件,開戶二級(jí)緩存;

                         <property name=”hibernate.cache.use_second_level_cache”>true</property>

                         *指定二級(jí)緩存產(chǎn)品的提供商;

    <property name=”hibernate.cache.provider_class”> org.hibernate.cache.EhCacheProvider

    </property>

    要讓那些實(shí)體使用二級(jí)緩存,在hibernate.cfg.xml配置文件中加入:

    <!—

    讓這個(gè)實(shí)體用二級(jí)緩存 也可以在實(shí)體中映射文件去配置即:

    <cache usage="read-only"/>

    -->

    <class-cache class=”com.zzz.hibernate.ClassT” usage=”read-only”/>

    Read-only一般使用這個(gè)策略,其它的hibernate3開發(fā)手冊(cè)中也有詳細(xì)介紹;

    CacheModehibernate3開發(fā)手冊(cè)中搜索這個(gè)關(guān)鍵字,可以找到一級(jí)緩存和二級(jí)緩存交互使用的問題;

    posted @ 2009-08-11 23:01 為自己代言 閱讀(7886) | 評(píng)論 (3)編輯 收藏

    這里為什么使用struts2.0.14這個(gè)版本呢??請(qǐng)看官網(wǎng)的文章如下:

    24 November 2008 - Struts 2.0.14 General Availability Release

    The latest release of Struts 2 is Struts 2.0.14, which was promoted to "General Availability" on 24 November 2008.

    For changes included in Struts 2.0.14, see the release notes. Struts 2.0.14 is a bugfix release for version 2.0.12, which provided important security fixes. Struts 2.0.14 addresses two major bugs introduced with these security fixes, keeping the FilterDispatcher from serving built in static resources, and keeping conversion error messages from being displayed. All developers are strongly encouraged to update existing Struts 2 applications to Struts 2.0.14.

    如果你的英語不差的話,自己去看下吧.這段英語的大概意思是,Struts 2.0.14修正了Struts 2.0.12 的兩個(gè)主要的bug ;并且建議開發(fā)者更新到Struts 2.0.14
    這個(gè)版本.Struts 2.0.14 General Availability Release 這是個(gè)通用的開發(fā)版本.
    其實(shí)我在整合這個(gè)S2SH時(shí),struts2 的最新版本是struts2.1.16 這個(gè)也是穩(wěn)家版本,不過最新的版本網(wǎng)上資料很少.所以...........! 如果自己學(xué)的話可以選擇這個(gè)兩個(gè)版本.
    下邊是整合的全過程:
    主要是jar包的引入,我個(gè)人比較不喜歡用IDE 工具自動(dòng)引入jar包,所以下邊是自己用的jar的引入,這樣可以省去相關(guān)jar 的沖突;

    1:首先struts2.0.14所需要的jar包如下:
    commons-logging-1.0.4  ;
    freemarker-2.3.8
     ognl-2.6.11
    struts2-core-2.0.14
    xwork-2.0.7
    struts2-spring-plugin-2.0.14  這是整合spring 必需的jar 包,從它的名字就可以看出來了!   

    2:hiberante3.2 jar 包如下 這是我的工程必需的,如果你的工程要用到其它的jar包可以去看一看hibernate 的必讀文件那里有很詳細(xì)的解釋;
                這個(gè)是做一般的工程,引入最少的jar 了,一般的項(xiàng)目都可以了!

    antlr-2.7.6         cglib-2.1.3     commons-collections-2.1.1    commons-logging-1.0.4      dom4j-1.6.1  
    ehcache-1.2.3    hibernate3     jaas        jaxen-1.1-beta-7     jdbc2_0-stdext     jta    log4j-1.2.11  
    xml-apis             asm             asm-attrs 

    如果你自己不做整合的,就是單獨(dú)做hibernate 學(xué)習(xí),本人建議你把所有jar 都導(dǎo)入項(xiàng)目的lib目錄下!這里不在做任何解釋了!

    3:  spring 2.5.6  相關(guān)的jar 也是做項(xiàng)目最少引入的jar包了,如果自己還需要特定的自己去引入;

        aspectjrt    aspectjweaver   ( 這兩個(gè)是AOP 相關(guān)的jar包,因?yàn)閟pring  2.5的AOP實(shí)現(xiàn),沒有自己去做,也用到了第三方組件,分開了,這好像和2.0版本有出入!有關(guān)細(xì)節(jié),請(qǐng)自己去查閱相關(guān)文檔)
        spring

    好的,這三個(gè)框架所有jar 包,都介紹完了,(不要奇怪我的所有jar 包沒有后綴名,是我自己給隱藏了)

    好的進(jìn)入主題了(順序最好 hibernate --->spring---->struts)

    1:把相關(guān)的hibernate  jar 包導(dǎo)入項(xiàng)目lib 目錄下!
    2: 把spring  相關(guān)jar   包導(dǎo)入項(xiàng)目lib 目錄下!
    3: 把struts2相關(guān)jar   包導(dǎo)入項(xiàng)目lib 目錄下!

    三者整合:
    web.xml文件如下里邊都有解釋自己看吧:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
     http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

     <!-- 配置spring監(jiān)聽器和上下文變量 -->
     <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/applicationContext-*.xml</param-value>
     </context-param>

     <listener>
      <listener-class>
       org.springframework.web.context.ContextLoaderListener
      </listener-class>
     </listener>
     <!-- spring end -->

    <!-- 配置字符過濾器-->
     <filter>
      <filter-name>encodingFilter</filter-name>
      <filter-class>
       org.springframework.web.filter.CharacterEncodingFilter
      </filter-class>
      <init-param>
       <param-name>encoding</param-name>
       <param-value>GBK</param-value>
      </init-param>
     </filter>
     <filter-mapping>
      <filter-name>encodingFilter</filter-name>
      <url-pattern>/*</url-pattern>
     </filter-mapping>

     <!--讓spring來過濾管理Hiberante中的session-->
     <filter>
      <filter-name>lazyLoadingFilter</filter-name>
      <filter-class>
       org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
      </filter-class>
     </filter>

     <!-- spring end -->

     <!-- 增加struts2所需要的過濾器,以便在服務(wù)器啟動(dòng)時(shí),攔截URL請(qǐng)求 -->
     <filter>
      <filter-name>struts2</filter-name>
      <filter-class>
       org.apache.struts2.dispatcher.FilterDispatcher
      </filter-class>
     </filter>

     <filter-mapping>
      <filter-name>lazyLoadingFilter</filter-name>
      <url-pattern>*.action</url-pattern>
     </filter-mapping>


     <filter-mapping>
      <filter-name>struts2</filter-name>
      <url-pattern>/*</url-pattern>
     </filter-mapping>
      </web-app>


    applicationContext-common.xml 文件:其中我使用了,DBCP數(shù)據(jù)庫連接波,如果你自己想用,
                               還的去下載相關(guān)的jar 包( commons-dbcp-1.2.2   commons-pool-1.3)記著引入哦!

    我下邊注釋掉的就是沒有用數(shù)據(jù)庫連接池的,也就是不把src目錄下的hibernate.cfg.xml刪除.上邊用到的數(shù)據(jù)庫連接池的,就不用這個(gè)文件了,直接都用spring來管理啦!!!!

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:aop="http://www.springframework.org/schema/aop"
     xmlns:tx="http://www.springframework.org/schema/tx"
     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
               http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
               http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
     <!-- 用DBCP數(shù)據(jù)庫連接波來配置hibernate數(shù)據(jù)庫連接 -->
     
      <bean id="dataSource"
      class="org.apache.commons.dbcp.BasicDataSource">
      <property name="driverClassName"
      value="com.mysql.jdbc.Driver">
      </property>
      <property name="url" value="jdbc:mysql://localhost/oa"></property>
      <property name="username" value="root"></property>
      <property name="password" value="root"></property>
      </bean>
     
     <!-- 配置sessionFactory -->
      
      <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
      <property name="dataSource">
      <ref bean="dataSource" />
      </property>
      <property name="hibernateProperties">
      <props>
      <prop key="hibernate.dialect">
      org.hibernate.dialect.MySQLDialect
      </prop>
      <prop key="hibernate.show_sql">true</prop>
      <prop key="format_sql">true</prop>
      <prop key="hibernate.hbm2ddl.auto">update</prop>
      </props>
      </property>
      <property name="mappingResources">
      <list>
      <value>com/oa/model/Person.hbm.xml</value>
      <value>com/oa/model/Organization.hbm.xml</value>
      </list>
      </property>
      </bean>
      
    <!-- 讓spring管理sessionFactory的加一種方法 ,就是不刪除hibernate.cfg.xml文件;
     <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
      <property name="configLocation">
       <value>classpath:hibernate.cfg.xml</value>
      </property>
     </bean>
    --> 
      
     <!-- 配置hibernate事物讓spring來管理 -->
     <bean id="transactionManager"
      class="org.springframework.orm.hibernate3.HibernateTransactionManager">
      <property name="sessionFactory">
       <ref bean="sessionFactory" />
      </property>
     </bean>
     <!-- 配置事物的傳播特性 -->
     <tx:advice id="txAdvice" transaction-manager="transactionManager">
      <tx:attributes>
       <tx:method name="add*" propagation="REQUIRED" />
       <tx:method name="delete*" propagation="REQUIRED" />
       <tx:method name="update*" propagation="REQUIRED" />
       <tx:method name="*" read-only="true" />
      </tx:attributes>
     </tx:advice>
     <!-- 那些類的那些方法需要事物; -->
     <aop:config>
      <aop:pointcut id="allManagerMethod"
       expression="execution(* com.oa.manager.*.*(..))" />
      <aop:advisor pointcut-ref="allManagerMethod"
       advice-ref="txAdvice" />
     </aop:config>
    </beans>

    對(duì)了還需要注意的一個(gè)地方就是如果用了,我這種數(shù)據(jù)庫連接池技術(shù),得把你的數(shù)據(jù)庫驅(qū)動(dòng)類,復(fù)制tomcat lib 目錄下.不然會(huì)報(bào)錯(cuò)的!

    好了三個(gè)東西整合好,我也是費(fèi)了九牛二虎之力才整合成功的.
    如果有什么問題發(fā)我的郵箱一起交流:zzzlyr@163.com



    posted @ 2009-07-11 00:03 為自己代言 閱讀(1651) | 評(píng)論 (1)編輯 收藏

    下面以三個(gè)頁面分別命名為framedemo.html,left.html,right.html為例來具體說明如何做。

    其中framedemo.html由左右兩個(gè)頁面組成,代碼如下:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> frameDemo </TITLE>
    </HEAD>
    <frameset cols="200,*">
    <frame name=top src="left.html">
    <frame name=button src="right.html">
    </frameset>
    </HTML>

    現(xiàn)在假設(shè)left.html即上面的頁面有一個(gè)button來實(shí)現(xiàn)對(duì)下面頁面的刷新,可以用以下七種語句,哪個(gè)好用自己看著辦了。

    語句1. window.parent.frames[1].location.reload();

    語句2. window.parent.frames.bottom.location.reload();

    語句3. window.parent.frames["bottom"].location.reload();

    語句4. window.parent.frames.item(1).location.reload();

    語句5. window.parent.frames.item('bottom').location.reload();

    語句6. window.parent.bottom.location.reload();

    語句7. window.parent['bottom'].location.reload();

    解釋一下:

    1.window指代的是當(dāng)前頁面,例如對(duì)于此例它指的是top.html頁面。

    2.parent指的是當(dāng)前頁面的父頁面,也就是包含它的框架頁面。例如對(duì)于此例它指的是framedemo.html。

    3.frames是window對(duì)象,是一個(gè)數(shù)組。代表著該框架內(nèi)所有子頁面。

    4.item是方法。返回?cái)?shù)組里面的元素。

    5.如果子頁面也是個(gè)框架頁面,里面還是其它的子頁面,那么上面的有些方法可能不行。
    top.html源代碼;(頁面上有七個(gè)按鈕,功能都是刷新下面的框架頁面)

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    </HEAD>
    <BODY>
    <input type=button value="刷新1" onclick="window.parent.frames[1].location.reload()"><br>
    <input type=button value="刷新2" onclick="window.parent.frames.bottom.location.reload()"><br>
    <input type=button value="刷新3" onclick="window.parent.frames['bottom'].location.reload()"><br>
    <input type=button value="刷新4" onclick="window.parent.frames.item(1).location.reload()"><br>
    <input type=button value="刷新5" onclick="window.parent.frames.item('bottom').location.reload()"><br>
    <input type=button value="刷新6" onclick="window.parent.bottom.location.reload()"><br>
    <input type=button value="刷新7" onclick="window.parent['bottom'].location.reload()"><br>
    </BODY>
    </HTML>

    下面是right.html頁面源代碼,為了證明下方頁面的確被刷新了,在裝載完頁面彈出一個(gè)對(duì)話框。

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    </HEAD>
    <BODY onload="alert('我被加載了!')">
    <h1>This is the content in button.html.</h1>
    </BODY>
    </HTML>

    經(jīng)我測(cè)試,只能1 和4 顯示效果,別的好像不對(duì)喲
    ============================

    附:
    Javascript刷新頁面的幾種方法:
    1    history.go(0)
    2    location.reload()
    3    location=location
    4    location.assign(location)
    5    document.execCommand('Refresh')
    6    window.navigate(location)
    7    location.replace(location)
    8    document.URL=location.href

     

     

     

    自動(dòng)刷新頁面的方法:
    1.頁面自動(dòng)刷新:把如下代碼加入<head>區(qū)域中
    <meta http-equiv="refresh" content="20">
    其中20指每隔20秒刷新一次頁面.

    2.頁面自動(dòng)跳轉(zhuǎn):把如下代碼加入<head>區(qū)域中
    <meta http-equiv="refresh" content="20;url=http://www.wyxg.com">
    其中20指隔20秒后跳轉(zhuǎn)到http://www.wyxg.com頁面

    3.頁面自動(dòng)刷新js版
    <script language="JavaScript">
    function myrefresh()
    {
           window.location.reload();
    }
    setTimeout('myrefresh()',1000); //指定1秒刷新一次
    </script>

    ASP.NET如何輸出刷新父窗口腳本語句
    1.   this.response.write("<script>opener.location.reload();</script>");  

    2.   this.response.write("<script>opener.window.location.href = opener.window.location.href;</script>");   

    3.   Response.Write("<script language=javascript>opener.window.navigate(''你要刷新的頁.asp'');</script>")


    JS刷新框架的腳本語句

    //如何刷新包含該框架的頁面用   
    <script language=JavaScript>
       parent.location.reload();
    </script>   

    //子窗口刷新父窗口
    <script language=JavaScript>
        self.opener.location.reload();
    </script>

    ( 或 <a href="javascript:opener.location.reload()">刷新</a>   )

    //如何刷新另一個(gè)框架的頁面用   
    <script language=JavaScript>
       parent.另一FrameID.location.reload();
    </script>

    如果想關(guān)閉窗口時(shí)刷新或者想開窗時(shí)刷新的話,在<body>中調(diào)用以下語句即可。

    <body onload="opener.location.reload()">
    開窗時(shí)刷新
    <body onUnload="opener.location.reload()">
    關(guān)閉時(shí)刷新

    <script language="javascript">
    window.opener.document.location.reload()
    </script>

    posted @ 2009-05-22 22:55 為自己代言 閱讀(4609) | 評(píng)論 (0)編輯 收藏

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>js退出使用!</title>
     <script language="javascript">
      function logout(){
      if( confirm("你確實(shí)要退出嗎??")){
       window.parent.location.;
      }
      else{
       return;
      }
     }
     </script>
    </head>
     <p> <a href="javascript:logout()"> 退出</a></p>
    <a href="javascript:history.back();">返回</a>
    <body>
    </body>
    </html>

    posted @ 2009-05-22 22:44 為自己代言 閱讀(5101) | 評(píng)論 (0)編輯 收藏

    <%@include file="/common/taglib.jsp"%>
    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>網(wǎng)站后臺(tái)管理系統(tǒng)</title>
     <%@include file="/common/metadata.jsp"%>
     <link href="${ctx}/admin/style/css_body.css" rel="stylesheet" type="text/css" />
     <script type="text/javascript">
          function del(id){
            if(confirm("您確認(rèn)要?jiǎng)h除該項(xiàng)嗎?")){
              document.location.href="${ctx}/NewsManage?action=deleteNews&id="+id;
            }else{
              return;
            }
          }
          function pagging(pageNo){
             document.location.href="${ctx}/MemeberRegisterServlet?action=list&pageNo="+pageNo;
         }
        </script>
    </head>
    <body>
     
      <div class="bodytitle">
        <div>
          <span class="bodytitletxt">新聞列表</span>
        </div>
      </div>
     
      <div class="list-div">
      <table border="0" cellpadding="10" cellspacing="1">
       <tr>
        <td align="center"><a href="${ctx}/NewsManage?action=refresh">刷新新聞列表</a></td>
        </tr>
      </table>
     
        <table border="0" cellpadding="10" cellspacing="1">
      
          <tr>
            <th>新聞編號(hào)</th>
            <th>新聞名稱</th>
            <th>發(fā)布者</th>
            <th>發(fā)布時(shí)間</th>
            <th>修改時(shí)間</th>
            <th>瀏覽次數(shù)</th>
            <th>操作</th>
          </tr>
          <c:forEach items="${newsList}" var="news">
          <tr>
            <td align="center">${news.id}</td>
            <td align="center"><a href="${ctx}/BrowerNewsServlet?action=browerNews&id=${news.id}">${news.topic}</a></td>
            <td align="center">${news.publishuser}</td>
            <td align="center">${news.publishtimes}</td>
            <td align="center">${news.modifytimes}</td>
            <td align="center">${news.hits}</td>
           <td align="center">
              <a href="${ctx}/NewsManage?action=modifyNews&id=${news.id}"><img src="${ctx}/icons/icon_edit.gif"></a>
              &nbsp;&nbsp;|&nbsp;&nbsp;
              <a href="javascript:del(${news.id})"><img src="${ctx}/icons/icon_drop.gif"></a>
            </td>
          </tr>
          </c:forEach>
          <tr>
            <td align="right" bgcolor="#f9ffe6" colspan="7"><%@include file="/common/paggingDiv.jsp" %></td>
          </tr>
        </table>
       
      </div>
     
      <div id="footer"><br />版權(quán)所有 &copy; 2005-2008 Onest's Studio 工作室,并保留所有權(quán)利。</div>

    </body>
    </html>

    posted @ 2009-05-22 22:18 為自己代言 閱讀(1865) | 評(píng)論 (0)編輯 收藏

    今天去面試了問我最簡單的JS對(duì)話框的使用,我竟然沒有回答上來!丟人,回來看了一個(gè)晚上的JS!好像懂點(diǎn)了。

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>三種彈出對(duì)話框的用法實(shí)例</title>
    <script language="javascript">
    function ale()
    {//這個(gè)基本沒有什么說的,就是彈出一個(gè)提醒的對(duì)話框 ,這個(gè)方法也可以帶參數(shù)的
        alert("提示對(duì)話框!");
    }
    function firm()
    {//利用對(duì)話框返回的值 (true 或者 false)
        if(confirm("你確信要轉(zhuǎn)去 天轟穿的博客?"))
        {//如果是true ,那么就把頁面轉(zhuǎn)向thcjp.cnblogs.com
            location.;
        }
        else
        {//否則說明下了,赫赫
            alert("你按了取消,那就是返回false");
        }
    }
    function prom()
    {
        var name=prompt("請(qǐng)輸入您的名字","");//將輸入的內(nèi)容賦給變量 name ,
        //這里需要注意的是,prompt有兩個(gè)參數(shù),前面是提示的話,后面是當(dāng)對(duì)話框出來后,在對(duì)話框里的默認(rèn)值
        if(name)//如果返回的有內(nèi)容
        {
            alert("歡迎您:"+ name)
        }
    }
    </script>
    </head>

    <body>
    <p>對(duì)話框有三種</p>
    <p>1:只是提醒,不能對(duì)腳本產(chǎn)生任何改變;</p>
    <p>2:一般用于確認(rèn),返回 true 或者 false ,所以可以輕松用于 ifelse判斷 </p>
    <p>3: 一個(gè)帶輸入的對(duì)話框,可以返回用戶填入的字符串,常見于某些留言本或者論壇輸入內(nèi)容那里的 插入U(xiǎn)BB格式圖片 </p>
    <p>下面我們分別演示:</p>
    <p>演示一:提醒 對(duì)話框</p>
    <p>
      <input type="submit" name="Submit" value="提交" onclick="ale()" />
    </p>
    <p>演示二 :確認(rèn)對(duì)話框 </p>
    <p>
      <input type="submit" name="Submit2" value="提交" onclick="firm()" />
    </p>
    <p>演示三 :要求用戶輸入,然后給個(gè)結(jié)果</p>
    <p>
      <input type="submit" name="Submit3" value="提交" onclick="prom()" />
    </p>
    </body>
    </html>

    posted @ 2009-05-22 22:15 為自己代言 閱讀(2587) | 評(píng)論 (0)編輯 收藏

    一、抽象類:

    抽象類是特殊的類,只是不能被實(shí)例化;除此以外,具有類的其他特性;重要的是抽象類可以包括抽象方法,這是普通類所不能的。抽象方法只能聲明于抽象類中,且不包含任何實(shí)現(xiàn),派生類必須覆蓋它們。另外,抽象類可以派生自一個(gè)抽象類,可以覆蓋基類的抽象方法也可以不覆蓋,如果不覆蓋,則其派生類必須覆蓋它們。

    二、接口:

    接口是引用類型的,類似于類,和抽象類的相似之處有三點(diǎn):

    1、不能實(shí)例化;

    2、包含未實(shí)現(xiàn)的方法聲明;

    3、派生類必須實(shí)現(xiàn)未實(shí)現(xiàn)的方法,抽象類是抽象方法,接口則是所有成員(不僅是方法包括其他成員);

    另外,接口有如下特性:
    接口除了可以包含方法之外,還可以包含屬性、索引器、事件,而且這些成員都被定義為公有的。除此之外,不能包含任何其他的成員,例如:常量、域、構(gòu)造函數(shù)、析構(gòu)函數(shù)、靜態(tài)成員。一個(gè)類可以直接繼承多個(gè)接口,但只能直接繼承一個(gè)類(包括抽象類)。

    三、抽象類和接口的區(qū)別:

    1.類是對(duì)對(duì)象的抽象,可以把抽象類理解為把類當(dāng)作對(duì)象,抽象成的類叫做抽象類.而接口只是一個(gè)行為的規(guī)范或規(guī)定,微軟的自定義接口總是后帶able字段,證明其是表述一類類“我能做。。。”.抽象類更多的是定義在一系列緊密相關(guān)的類間,而接口大多數(shù)是關(guān)系疏松但都實(shí)現(xiàn)某一功能的類中.

    2.接口基本上不具備繼承的任何具體特點(diǎn),它僅僅承諾了能夠調(diào)用的方法;    

    3.一個(gè)類一次可以實(shí)現(xiàn)若干個(gè)接口,但是只能擴(kuò)展一個(gè)父類    

    4.接口可以用于支持回調(diào),而繼承并不具備這個(gè)特點(diǎn).    

    5.抽象類不能被密封。  

    6.抽象類實(shí)現(xiàn)的具體方法默認(rèn)為虛的,但實(shí)現(xiàn)接口的類中的接口方法卻默認(rèn)為非虛的,當(dāng)然您也可以聲明為虛的.

    7.(接口)與非抽象類類似,抽象類也必須為在該類的基類列表中列出的接口的所有成員提供它自己的實(shí)現(xiàn)。但是,允許抽象類將接口方法映射到抽象方法上。  

    8.抽象類實(shí)現(xiàn)了oop中的一個(gè)原則,把可變的與不可變的分離。抽象類和接口就是定義為不可變的,而把可變的座位子類去實(shí)現(xiàn)。

    9.好的接口定義應(yīng)該是具有專一功能性的,而不是多功能的,否則造成接口污染。如果一個(gè)類只是實(shí)現(xiàn)了這個(gè)接口的中一個(gè)功能,而不得不去實(shí)現(xiàn)接口中的其他方法,就叫接口污染。  

    10.盡量避免使用繼承來實(shí)現(xiàn)組建功能,而是使用黑箱復(fù)用,即對(duì)象組合。因?yàn)槔^承的層次增多,造成最直接的后果就是當(dāng)你調(diào)用這個(gè)類群中某一類,就必須把他們?nèi)考虞d到棧中!后果可想而知.(結(jié)合堆棧原理理解)。同時(shí),有心的朋友可以留意到微軟在構(gòu)建一個(gè)類時(shí),很多時(shí)候用到了對(duì)象組合的方法。比如asp.net中,Page類,有Server Request等屬性,但其實(shí)他們都是某個(gè)類的對(duì)象。使用Page類的這個(gè)對(duì)象來調(diào)用另外的類的方法和屬性,這個(gè)是非常基本的一個(gè)設(shè)計(jì)原則。  

    11.如果抽象類實(shí)現(xiàn)接口,則可以把接口中方法映射到抽象類中作為抽象方法而不必實(shí)現(xiàn),而在抽象類的子類中實(shí)現(xiàn)接口中方法.

    四、抽象類和接口的使用:

    1. 如果預(yù)計(jì)要?jiǎng)?chuàng)建組件的多個(gè)版本,則創(chuàng)建抽象類。抽象類提供簡單的方法來控制組件版本。

    2.如果創(chuàng)建的功能將在大范圍的全異對(duì)象間使用,則使用接口。如果要設(shè)計(jì)小而簡練的功能塊,則使用接口。

    3.如果要設(shè)計(jì)大的功能單元,則使用抽象類.如果要在組件的所有實(shí)現(xiàn)間提供通用的已實(shí)現(xiàn)功能,則使用抽象類。  

    4.抽象類主要用于關(guān)系密切的對(duì)象;而接口適合為不相關(guān)的類提供通用功能。

    以下是我在網(wǎng)上看到的幾個(gè)形象比喻,真的非常不錯(cuò),呵呵:

    1.飛機(jī)會(huì)飛,鳥會(huì)飛,他們都繼承了同一個(gè)接口“飛”;但是F22屬于飛機(jī)抽象類,鴿子屬于鳥抽象類。

    2. 就像鐵門木門都是門(抽象類),你想要個(gè)門我給不了(不能實(shí)例化),但我可以給你個(gè)具體的鐵門或木門(多態(tài));而且只能是門,你不能說它是窗(單繼承);一個(gè)門可以有鎖(接口)也可以有門鈴(多實(shí)現(xiàn))。 門(抽象類)定義了你是什么,接口(鎖)規(guī)定了你能做什么(一個(gè)接口最好只能做一件事,你不能要求鎖也能發(fā)出聲音吧(接口污染)

    posted @ 2009-05-12 11:06 為自己代言 閱讀(1469) | 評(píng)論 (0)編輯 收藏

         摘要:   閱讀全文

    posted @ 2009-05-11 09:09 為自己代言 閱讀(487) | 評(píng)論 (1)編輯 收藏

         摘要:   閱讀全文

    posted @ 2009-04-01 11:18 為自己代言 閱讀(2459) | 評(píng)論 (5)編輯 收藏

    僅列出標(biāo)題
    共2頁: 上一頁 1 2 
    主站蜘蛛池模板: 真人做A免费观看| 亚洲免费精彩视频在线观看| 免费人成在线观看69式小视频| 人成免费在线视频| 亚洲深深色噜噜狠狠网站| 久久久久久亚洲精品| 亚洲中文字幕无码一区| 免费看国产曰批40分钟| 97无码免费人妻超级碰碰碰碰| 日韩午夜理论免费TV影院| aa在线免费观看| 一区二区三区免费在线视频| 亚洲AV噜噜一区二区三区| 亚洲欧洲日韩国产一区二区三区 | 精品久久亚洲一级α| 亚洲国产高清视频在线观看| 亚洲Av无码精品色午夜| 亚洲午夜福利在线观看| 国产亚洲自拍一区| 亚洲日韩国产一区二区三区| 免费A级毛片在线播放不收费| 国产精品久久香蕉免费播放| 午夜成人免费视频| 在线观看人成视频免费| 午夜免费福利影院| 热久久精品免费视频| 日韩成人免费aa在线看| 国产高清在线精品免费软件| 日本一道本高清免费| 四虎影视在线永久免费观看| 国产无遮挡裸体免费视频| 国产免费人成在线视频| 免费在线一级毛片| 亚洲国产中文字幕在线观看| 亚洲视频在线一区二区| 亚洲一区二区三区影院| 亚洲成色在线影院| 亚洲成人高清在线观看| 国产精品亚洲精品| 国产精品手机在线亚洲| h视频在线观看免费|