176142998

            BlogJava :: 首頁(yè) :: 聯(lián)系 :: 聚合  :: 管理
            116 Posts :: 0 Stories :: 45 Comments :: 0 Trackbacks

          #

          分析:EOFException表示輸入過(guò)程中意外地到達(dá)文件尾或流尾的信號(hào),導(dǎo)致從session中獲取數(shù)據(jù)失敗。異常是tomcat本身的問(wèn)題,由于tomcat上次非正常關(guān)閉時(shí)有一些活動(dòng)session被持久化(表現(xiàn)為一些臨時(shí)文件),在重啟時(shí),tomcat嘗試去恢復(fù)這些session的持久化數(shù)據(jù)但又讀取失敗造成的。此異常不影響系統(tǒng)的使用。
          解決辦法:將tomcat5.5\work\Catalina\localhost\peam\SESSIONS.ser刪除。如果正常關(guān)閉服務(wù)端,該文件是自動(dòng)刪除的。
          posted @ 2008-07-09 22:59 飛飛 閱讀(210) | 評(píng)論 (0)編輯 收藏

          當(dāng)增加Hibernate Capabilites后增加Struts Capabilites,運(yùn)行項(xiàng)目時(shí),控制臺(tái)報(bào)錯(cuò)信息:
          /----------------------------------------------org.apache.commons.collections.SequencedHashMap
          ......
          /----------------------------------------------
          解決方案:
          下載commons-beanutils-1.7.0.zip;
          將其中commons-beanutils.jar文件替換Tomcat6.0下WEB-INF/lib/commons-beanutils-1.7;
          解決問(wèn)題.

          這個(gè)錯(cuò)誤可能是myeclipse6.0版本的一個(gè)問(wèn)題,就是在整合web層和struts層出現(xiàn)的問(wèn)題

          解決方法如下:

          1)下載6.0.1版本的myeclipse開(kāi)發(fā)

          2)下載最新的org.apache.commons.collections,講原來(lái)的去掉就行了,然后講最新的加進(jìn)去

          posted @ 2008-07-09 20:53 飛飛 閱讀(784) | 評(píng)論 (0)編輯 收藏

          <html:messages>
          Action 中 :
                  ActionMessages message = new ActionMessages();
                  message.add(" 消息句柄 ",new ActionMessage(" 資源文件中 Key 值 ",String 類型描述信息 ));
                  this.addMessages(request,message);
                  return ActionForward;
          JSP 頁(yè)面中 :
                  <html:messages id=" 指定使用消息的標(biāo)識(shí) " property=" 消息句柄 " message="true|false">
                     <bean:write name=" 以上所指 ID 標(biāo)識(shí) "/>
                  </html:messages>

          例如:

          Action方法中:
          saveMessage(request,"頁(yè)面要顯示的消息");

          Action的調(diào)用的方法,可以寫真Action實(shí)現(xiàn)類的父類 BaseDispatchAction :

          public ActionMessages saveMessage(HttpServletRequest request, String key) {
                ActionMessages messages = new ActionMessages();
                return saveMessage(messages, request, key);
          }

          protected ActionMessages saveMessage(ActionMessages messages,
                 HttpServletRequest request, String key) {

                messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(key));
                saveMessages(request, messages);
                return messages;
          }

          頁(yè)面:

          <html:messages id="msg" message="true"><bean:write name="msg"/></html:messages>

           

          <html:errors>
          Action 中 :
                  ActionMessages message = new ActionMessages();
                  message.add(" 消息句柄 ",new ActionMessage(" 資源文件中 Key 值 ",String 類型描述信息 ));
                  this.saveErrors(request,message);
                  return ActionForward;
          JSP 頁(yè)面中 :
                  <html:errors property=" 消息句柄 "/>

          如果Action中這樣設(shè)定(false),頁(yè)面的提示信息將不從資源文件里讀取:
                  ActionMessages message = new ActionMessages();
                  message.add("消息句柄",new ActionMessage("String類型描述信息));",false));
                  this.saveErrors(request,message);
                  return ActionForward;
          JSP頁(yè)面:
                  <html:errors/>或<html:errors property="消息句柄"/>

          posted @ 2008-07-09 17:21 飛飛 閱讀(337) | 評(píng)論 (0)編輯 收藏

          源碼下載:http://ishare.iask.sina.com.cn/cgi-bin/fileid.cgi?fileid=2857703

          1. 準(zhǔn)備

          工具:MyEclipse 6.0.1 GA、mysql-connector-java-5.0.4-bin.jar、MySql GUI Tools 5.0(便于管理MySql數(shù)據(jù)庫(kù),不是必須)

          環(huán)境:Tomcat 5.5、MySql 5.0

          1.1. 新建工程

          操作:[Menu] File/New/Web Project

          工程名:login

          2. Struts 部分


          2.1. 添加 Struts 功能支持

          操作:[Menu] MyEclipse/Project Capabilities/Add Struts Capabilities

           

          2.2. 創(chuàng)建 ActionForm 類

          操作:[Ctrl+N] MyEclipse/Web-Struts/Struts 1.2 Form

          類名:LoginForm

          在 “Form Properties” 選項(xiàng)卡為 loginForm 新增兩個(gè)屬性:username、password;

          在 “JSP” 選項(xiàng)卡鉤選 “Create JSP form” 選項(xiàng),將新建路徑改為 “/login.jsp”(login.jsp文件將被自動(dòng)創(chuàng)建)。

          2.3. 創(chuàng)建 Action 類

          操作:[Ctrl+N] MyEclipse/Web-Struts/Struts 1.2 Action

          類名:LoginAction

          在 “Form” 選項(xiàng)卡的 “Name” 項(xiàng)選擇 “loginForm”,”Input Source” 項(xiàng)輸入 “/login.jsp”。

          2.4. 創(chuàng)建 index.jsp 文件

          如果沒(méi)有,創(chuàng)建 index.jsp 文件,并添加一個(gè)指向 login.jsp 的鏈接:<a href=”login.jsp”>Login</a>。

          2.5. 創(chuàng)建Forword類

          操作:[Ctrl+N] MyEclipse/Web-Struts/Struts 1.2 Forword

          類名:indexForword

          “Name” 項(xiàng)輸入 “indexForword” ,”Path” 項(xiàng)輸入 “/index.jsp” 。

          2.6. 修改 LoginAction.java 文件

          修改 LoginAction 類的 execute 方法:

          public class LoginAction extends Action {

          public ActionForward execute(ActionMapping mapping, ActionForm form,
          HttpServletRequest request, HttpServletResponse response) {
          LoginForm loginForm = (LoginForm) form;
          String username=loginForm.getUsername();
          String password=loginForm.getPassword();
          if(username.equals(”test”)||password.equals(”test”)){
          return mapping.findForward(”indexForword”);
          }else{
          return mapping.getInputForward();
          }
          }
          }

          2.7. 修改 login.jsp 文件

          修改 <html:form> 標(biāo)簽:<html:form action=”/login”>。

          2.8. 測(cè)試

          操作:[Menu] Run/Run,選擇 MyEclipse Server Application 方式運(yùn)行

          要正常執(zhí)行Run操作,需先安裝 Tomcat5.5 。

          點(diǎn)擊 index.jsp 頁(yè)面的 “Login” 鏈接,跳轉(zhuǎn)到 login.jsp 頁(yè)面。在 login.jsp 頁(yè)面輸入 “test/test”,應(yīng)該會(huì)登錄成功,然后跳轉(zhuǎn)到 index.jsp 頁(yè)面;輸入 “test/123″ ,應(yīng)該保持在 login.jsp 頁(yè)面。

          如果測(cè)試成功,證明 Structs 運(yùn)行正常。

          3. Spring 部分


          3.1. 添加 Spring 功能支持

          操作:[Menu] MyEclipse/Project Capabilities/Add Spring Capabilities

          Spring 版本( Spring version )選擇 “Spring 1″;

          開(kāi)發(fā)包(libraries)選擇 “Spring 1.2 AOP Libraries、Spring 1.2 Core Libraries、Spring 1.2 Persistence Core Libraries、Spring 1.2 Persistence JDBC Libraries” 四項(xiàng);

          JAR Library Installation 選擇 “copy checked…” ,”Library Folder” 項(xiàng)選擇 “/WebRoot/WEB-INF/lib”(這樣的話所需的類庫(kù)都將拷貝到項(xiàng)目目錄,方便以后的布署)。

          點(diǎn)擊 “下一步(Next)” 創(chuàng)建配置文件,修改文件路徑(Folder)到 “WebRoot/WEB-INF” 目錄(以便和Struts配置文件一起管理),文件名稱為默認(rèn)的”applicationContext.xml”。

          點(diǎn)擊 “完成(Finish)” 。

          3.2. 配置 struts-config.xml 文件

          添加 Spring 插件(在 <message-resources> 標(biāo)簽后面添加):

          <plug-in className=”org.springframework.web.struts.ContextLoaderPlugIn”>
          <set-property property=”contextConfigLocation” value=”/WEB-INF/applicationContext.xml” />
          </plug-in>

          修改 LoginAction 的配置(只需修改 type 屬性):

          <action-mappings >
          <action
          attribute=”loginForm”
          input=”/login.jsp”
          name=”loginForm”
          path=”/login”
          scope=”request”
          type=”org.springframework.web.struts.DelegatingActionProxy” />

          </action-mappings>

          綠色字體部份為被修改過(guò)的內(nèi)容,這里將使用 spring 的代理器 DelegatingActionProxy 來(lái)對(duì) Action 進(jìn)行控制。

          3.3. 修改 Spring 配置文件 applicationContext.xml

          <?xml version=”1.0″ encoding=”UTF-8″?>
          <!DOCTYPE beans PUBLIC “-//SPRING//DTD BEAN//EN” “http://www.springframework.org/dtd/spring-beans.dtd”>

          <beans>
          <bean name=”/login” class=”com.login.struts.action.LoginAction” singleton=”false”></bean>
          </beans>

          綠色字體是關(guān)于接受和處理 Action 控制權(quán)的配置內(nèi)容,”com.login.struts.action.LoginAction” 即為原 struts 里的配置。

          3.4. 測(cè)試

          同上一次測(cè)試。測(cè)試成功證明 Spring 運(yùn)行正常。

          4. Hibernate 部分

          下面開(kāi)始 Hibernate 部分,將原例修改為使用數(shù)據(jù)庫(kù)進(jìn)行用戶名/密碼驗(yàn)證。

          4.1. 創(chuàng)建 mysql 數(shù)據(jù)庫(kù)和表

          添加表的代碼如下:

          CREATE TABLE user_table(
          ID int NOT NULL auto_increment,
          USERNAME varchar(45) NOT NULL default ”,
          PASSWORD varchar(45) NOT NULL default ”,
          PRIMARY KEY (ID)
          )

          再添加一條記錄:

          insert into user_table (USERNAME,PASSWORD) values (’test’,'test’)

          4.2. 創(chuàng)建 MyEclipse 數(shù)據(jù)庫(kù)驅(qū)動(dòng)(DB Driver)

          操作:[Menu] MyEclipse/Prefrences/MyEclipse/Database Explorer/Database Driver/DB Brower

          在 DB Brower 的菜單中選擇 “New” ,”Driver Name” 項(xiàng)輸入 “login-conn” ,”Connection URL” 項(xiàng)輸入 “jdbc:mysql://localhost:3306/test” ,然后輸入正確的用戶名(User Name)和密碼(Password)按實(shí)際情況輸入;

          在 “Driver JARs” 項(xiàng)添加 “mysql-connector-java-5.0.4-bin.jar” (可從網(wǎng)上下載),在 “Driver classname” 里選擇 “com.mysql.jdbc.Driver” ,其它自選。

          點(diǎn)擊 “完成(Finish)”。

          4.3. 添加 Hibernate 功能支持

          操作:[Menu] MyEclipse/Project Capabilities/Add Hibernate Capabilities

          Hibernate 版本(Hibernate Specification)選擇 “Hibernate 3.1″ ,開(kāi)發(fā)包(libraries)選擇 Hibernate 3.1 Core Libraries 一項(xiàng);

          JAR Library Installation 選擇 “copy checked…” ,”Library Folder” 選擇 “/WebRoot/WEB-INF/lib” 。

          點(diǎn)擊 “下一步(Next)” 設(shè)置配置文件,選擇 “Spring configuration file (applicationContext.xml)” 。

          “下一步(Next)” 設(shè)置 Spring-Hibernate,選擇 “Existing Spring configuration file” ,”SessionFactory ID” 項(xiàng)輸入 “sessionFactory” 。

           

          “下一步(Next)” 創(chuàng)建數(shù)據(jù)源對(duì)象,在 Bean Id 中輸入 dataSource,”DataSource” 項(xiàng)選擇 “Use JDBC Dirver” ,DB Driver 項(xiàng)選擇 “login-conn” ,其余項(xiàng)會(huì)自動(dòng)填充;

          記得選中 “Copy DB driver jar(s) to project and add to buidpath” 項(xiàng),以便將數(shù)據(jù)連接的庫(kù)文件復(fù)制到項(xiàng)目,方便以后的布署。

          “下一步(Next)” 創(chuàng)建 SessionFactory 類,”Java package” 項(xiàng)設(shè)置為 “com.login.Hibernate” (沒(méi)有則點(diǎn)擊”New”按鈕添加),”Class name” 項(xiàng)修改為”SessionFactory” ,Java Compliance Level選擇和創(chuàng)建項(xiàng)目時(shí)選擇的Java版本。(本例中并沒(méi)有用到SessionFactory類,留作今后擴(kuò)展)

          點(diǎn)擊 “完成(Finish)”。

          4.4. 創(chuàng)建對(duì)象關(guān)系映射(ORM)的相關(guān)文件

          操作:[Menu] Window/Open Perspective/MyEclipse Database Explorer

          選中 user_table 表,點(diǎn)擊右鍵,在出現(xiàn)的菜單中選擇 “Hibernate Reverse Engnieering” 。

          在彈出的窗口中保持 “Java package” 項(xiàng)為 “com.login” ;

          選中 “Hibernate mapping file (*.hbm.xml) for each databases table” ,并保持 “Update hibernate…” 項(xiàng)選中;

          選中 “Java Data Object” 項(xiàng),并保持 “Create abstract class” 選中;

          “Base persistent class” 項(xiàng)留空;

          取消 “Java Data Access Object…” 項(xiàng)和 “Use custom templates” 項(xiàng)。

          點(diǎn)擊 “下一步(Next)” ,再點(diǎn)擊 “下一步(Next)” ,在 “Configure reverse engineering details” 頁(yè)選中 “user_table” 表,在右邊出現(xiàn)的 “Class Name” 項(xiàng)中輸入 “com.login.User”,其它不變。

          點(diǎn)擊 “完成(Finish)”。

          完成此操作,會(huì)在 “com.login” 包下創(chuàng)建三個(gè)文件:AbstractUser.java、User.java、User.hbm.xml。

          4.5. 創(chuàng)建 UserDAO.java 接口和 UserDAOImpl.java 類

          UserDAO 和 UserDAOImpl 通過(guò) Hibernate 訪問(wèn)數(shù)據(jù)庫(kù)。

          UseDAO.java 內(nèi)容如下:

          package com.login;

          public interface UserDAO {
          public abstract boolean isValidUser(String username, String password);
          }

          UserDAOImpl.java 內(nèi)容如下:

          package com.login;

          import java.util.List;
          import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

          public class UserDAOImpl extends HibernateDaoSupport implements UserDAO {
          private static String hql = “from User u where u.username=? “;

          public boolean isValidUser(String username, String password) {
          // 驗(yàn)證用戶
          List userList = this.getHibernateTemplate().find(hql, username);
          if (userList.size() > 0) {
          return true;
          }
          return false;
          }
          }

          4.6. 修改 LoginAction.java 文件

          使用 UseDAO 對(duì)象來(lái)驗(yàn)證:

          package com.login.struts.action;

          import javax.servlet.http.HttpServletRequest;
          import javax.servlet.http.HttpServletResponse;
          import org.apache.struts.action.Action;
          import org.apache.struts.action.ActionForm;
          import org.apache.struts.action.ActionForward;
          import org.apache.struts.action.ActionMapping;
          import com.login.struts.form.LoginForm;
          import com.login.UserDAO;

          public class LoginAction extends Action {
          private UserDAO userDAO;

          public UserDAO getUserDAO() {
          return userDAO;
          }

          public void setUserDAO(UserDAO userDAO) {
          this.userDAO = userDAO;
          }

          public ActionForward execute(ActionMapping mapping, ActionForm form,
          HttpServletRequest request, HttpServletResponse response) {

          LoginForm loginForm = (LoginForm) form;
          String username=loginForm.getUsername();
          String password=loginForm.getPassword();

          if( userDAO.isValidUser( username, password ) ){
          return mapping.findForward( “indexForword” );
          }else{
          return mapping.getInputForward();
          }
          }
          }

          綠色字體為修改部分。

          4.7. Spring 的最終配制文件 applicationContext.xml

          <?xml version=”1.0″ encoding=”UTF-8″?>
          <!DOCTYPE beans PUBLIC “-//SPRING//DTD BEAN//EN” “http://www.springframework.org/dtd/spring-beans.dtd”>

          <beans>

          <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:3306/test”></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 local=”dataSource” />
          </property>
          <property name=”mappingResources”>
          <list>
          <value>com/login/User.hbm.xml</value>
          </list>
          </property>
          <property name=”hibernateProperties”>
          <props>
          <prop key=”hibernate.dialect”>org.hibernate.dialect.MySQLDialect</prop>
          <prop key=”hibernate.show_sql”>true</prop>
          </props>
          </property>
          </bean>

          <bean id=”transactionManager” class=”org.springframework.orm.hibernate3.HibernateTransactionManager”>
          <property name=”sessionFactory”>
          <ref local=”sessionFactory” />
          </property>
          </bean>

          <bean id=”userDAO” class=”com.login.UserDAOImpl”>
          <property name=”sessionFactory”>
          <ref local=”sessionFactory” />
          </property>
          </bean>

          <bean id=”userDAOProxy” class=”org.springframework.transaction.interceptor.TransactionProxyFactoryBean”>
          <property name=”transactionManager”>
          <ref bean=”transactionManager” />
          </property>
          <property name=”target”>
          <ref local=”userDAO” />
          </property>
          <property name=”transactionAttributes”>
          <props>
          <prop key=”insert*”>PROPAGATION_REQUIRED</prop>
          <prop key=”get*”>PROPAGATION_REQUIRED,readOnly</prop>
          <prop key=”is*”>PROPAGATION_REQUIRED,readOnly</prop>
          </props>
          </property>
          </bean>

          <bean name=”/login” class=”com.login.struts.action.LoginAction” singleton=”false”>
          <property name=”userDAO”>
          <ref bean=”userDAOProxy” />
          </property>
          </bean>

          </beans>

          4.8. 測(cè)試

          同第一次測(cè)試。 

          posted @ 2008-07-09 14:13 飛飛 閱讀(3472) | 評(píng)論 (2)編輯 收藏

          在spring2.0中,bean沒(méi)有“singleton”這個(gè)屬性,而是在“scope”中對(duì)它進(jìn)行設(shè)定。“scope”可以設(shè)定為“singleton”和“prototype”默認(rèn)情況下是“singleton”即和原先的“singleton=true”性質(zhì)一樣,如果要實(shí)現(xiàn)單例模式則將“scope”設(shè)定為“prototype”,即和原先版本的“singleton=false”一樣。參考文檔鏈接地址:http://www.springframework.org/schema/beans/spring-beans-2.0.xsd



          根據(jù)用戶名和密碼進(jìn)行校驗(yàn)的方法
           public boolean verify(String userName, String userPwd) {
            final String HQL="FROM UserTable u where u.userName=? and u.userPwd=?";
            String[] hqlParameter=new String[2];
            hqlParameter[0]=userName;
            hqlParameter[1]=userPwd;
            List list=this.getHibernateTemplate().find(HQL,hqlParameter);
            if(list.size()>0){
             return true;
            }
            
            return false;
           }
          posted @ 2008-07-09 13:03 飛飛 閱讀(2963) | 評(píng)論 (0)編輯 收藏

          mysql-administrator的安裝與使用(圖文)
            
          準(zhǔn)備工作
          在D盤建立一個(gè)mysql-software的目錄,把剛才下載的 mysql-administrator-1.0.19-win-noinstall.zip 復(fù)制到這個(gè)子目錄中,解壓,得到一個(gè) MySQL Administrator 1.0 的目錄。
          同樣如此操作 mysql-query-browser-1.1.5-win-noinstall.zip,得到一個(gè) MySQL Query Browser 1.1 的目錄。
            
          啟動(dòng)服務(wù)
          ·
          雙擊D:mysql-softwareMySQL Administrator 1.0 目錄下的 MySQLSystemTrayMonitor.exe,這時(shí)會(huì)在任務(wù)欄右側(cè)出現(xiàn)一個(gè)圖標(biāo)。點(diǎn)擊“Start Instance”,運(yùn)行MySQL。

          ·
          然后雙擊 D:mysql-softwareMySQL Administrator 1.0 目錄中的 MySQLAdministrator.exe,或者直接點(diǎn)擊上面右鍵菜單中的“MySQL Administrator ”:

          ·
          創(chuàng)建一個(gè)連接名,可以隨便填,這里是“mxj”,用戶名:root,密碼空著。這是因?yàn)閙ysql默認(rèn)有一個(gè)沒(méi)有密碼的root帳號(hào)。點(diǎn)擊“OK”,出現(xiàn)管理窗口:

          這沒(méi)什么好說(shuō)的,英文也很簡(jiǎn)單。只談?wù)勆厦婀催x的兩項(xiàng)。
          更改密碼

          好了,我的root帳號(hào)的密碼設(shè)置為:javamxj    最后,點(diǎn)擊“Apply Change”。
          ● 初始的

          數(shù)據(jù)庫(kù)



          上圖可以看到,初始有兩個(gè)

          數(shù)據(jù)庫(kù)

          ,mysql庫(kù)中含有各種配置信息,不要在這個(gè)庫(kù)中進(jìn)行表操作。
          test庫(kù)初始是空的。另外,建立表時(shí),不要和mysql庫(kù)中的表名取名相同,以免沖突。
          數(shù)據(jù)創(chuàng)建與查詢(兼談?wù)勛址幋a)
          ·
          現(xiàn)在來(lái)到查詢?yōu)g覽器,還是右擊右下角“MySQL System Tray Monitor”圖標(biāo),從中選擇“MySQL Query Browser”,因?yàn)橐呀?jīng)更改過(guò)root的密碼,所以要填入新密碼。

          ·
          進(jìn)入主界面,右擊test

          數(shù)據(jù)庫(kù)

          ,創(chuàng)建一個(gè)新表。

          ·
          如下簡(jiǎn)單創(chuàng)建一個(gè)表

          ·
          切換到“Table Options”:

          如果了解

          數(shù)據(jù)庫(kù)

          的話,這些應(yīng)該是很熟悉的,不多說(shuō)了。注意字符設(shè)置默認(rèn)是“Latin1”(保存改變,再次切換到這一欄,就能看到了)。
          ·
          填入一些測(cè)試數(shù)據(jù):

          ·
          關(guān)閉“MySQL Query Browser”,再重新打開(kāi)它,切換到testtable表,看到了沒(méi)有?剛才輸入的中文變成了“??????”,為什么呢? 再次切換到“Table Options”:

          知道為什么了吧,原來(lái)默認(rèn)字符是“latin1”,因?yàn)镸ySQL是瑞典一家公司的產(chǎn)品。中國(guó)人看來(lái)要努力了!
          ● 解決方法:
          ·
          停止MySql服務(wù),關(guān)閉所有與MySql相關(guān)的程序,打開(kāi)Windows的系統(tǒng)安裝目錄下的 my.ini 文件,如下修改:
          E:WINDOWSmy.ini

          [WinMySQLAdmin]
            
          Server

          =D:/mysql/bin/mysqld-nt.exe
            
          [mysqld]
            
          basedir
          =D:/mysql
            
          datadir
          =D:/mysql-data/data
            
          default-character-set
          =gbk
            
          [client]
            
          default-character-set
          =gbk
          添加的兩條語(yǔ)句的含義是在客戶端和服務(wù)端都使用GBK字符集進(jìn)行編碼。
          保存后,重新激活 MySql 服務(wù),打開(kāi)“MySQL Query Browser”,再次創(chuàng)建一個(gè)表,輸入中文,一切OK!

          備份時(shí)會(huì)出錯(cuò),以下日志:
          ----------------------------------------
          2008-07-03 14:18 - Backup started.
          Preparing backup for for profile mysql.
          Connections loaded from file C:\Documents and Settings\Administrator\Application Data\MySQL\mysqlx_user_connections.xml.
          Connection NewConnection selected.
          Cannot connect to MySQL Server. Access denied for user 'root'@'localhost' (using password: NO) (Error Number 1045)

          在mysqlx_user_connections.xml.文件中加個(gè)密碼進(jìn)去
          <?xml version="1.0"?>
          <user_connections>
            <last_connection>0</last_connection>
            <password_storage_type>2</password_storage_type>
            <user_connection>
              <connection_name>NewConnection</connection_name>
              <username>root</username>
              <hostname>127.0.0.1</hostname>
              <port>3306</port>
              <schema>test</schema>
              <advanced_options/>
              <storage_path></storage_path>
              <notes></notes>
              <connection_type>0</connection_type>
              <storage_type>1</storage_type>
              <password_storage_type>2</password_storage_type>
              <password>root</password>
            </user_connection>
          </user_connections>

          但是在備份的時(shí)候還是會(huì)出現(xiàn)錯(cuò)誤

          根據(jù)提示選擇open options 選擇 password storage
          OK
          電腦每次自己?jiǎn)?dòng)MySQLSystemTrayMonitor 就會(huì)在定制的時(shí)間備份數(shù)據(jù)庫(kù)

          Your account information:
          Name: fei zhao
          Email: feifeixia2003@yahoo.com.cn
          Password: nehaifrowa
          You can log in to your new account and edit your profile options at:
            http://www.mysql.com/login.php
          posted @ 2008-07-03 13:54 飛飛 閱讀(10079) | 評(píng)論 (1)編輯 收藏

          http://www.net.cn/static/customercare/support/demo/outlook/outlook.htm
          fei.zhao@centralsoft.com.cn
          211.155.226.126
          posted @ 2008-07-02 09:22 飛飛 閱讀(975) | 評(píng)論 (0)編輯 收藏

          有些事情現(xiàn)在已經(jīng)很容易被忘記了,但是在開(kāi)發(fā)原創(chuàng)的 Mac OS 的時(shí)候,業(yè)界到處出現(xiàn)新的圖形用戶接口(GUI),人們所做的工作差別相當(dāng)小。Macintosh 的設(shè)計(jì)團(tuán)隊(duì)在很多事情上是正確的,這很大程度上是因?yàn)樗麄冊(cè)谧约赫诟墒裁催@個(gè)問(wèn)題上付出了難以想像的思考。雖然我要為 Internet Developer(英特網(wǎng)開(kāi)發(fā)者)書(shū)寫一些腳本方面的集體思想,但我還是想去看一些過(guò)去的 Macintosh 人機(jī)界面指南,并且看看這些指導(dǎo)原則如何才能用到 Web 界面上,我認(rèn)為這是很值當(dāng)?shù)摹N液苌偃フ铱梢钥截惖木唧w部件,而更多地尋找這個(gè)以友好聞名的界面后面隱藏的設(shè)計(jì)原則。

          原則之一就是無(wú)模式。這個(gè)原則打動(dòng)了我,因?yàn)樗貏e適合于 Web。正如 Mac 的設(shè)計(jì)者描述的那樣,模式界面(在這種界面下,您能做什么取決于您當(dāng)前處于什么模式下)會(huì)“把用戶鎖定在一個(gè)操作上,用戶在該操作完成之前不允許進(jìn)行其它任何操作”。使用單純的老版本HTML時(shí),從某種意義上看,所有界面都是模式的,進(jìn)行任何修改都需要裝載一個(gè)新的頁(yè)面。舉例來(lái)說(shuō),假定您在填充一個(gè)表單時(shí)需要一些幫助,則您必須轉(zhuǎn)到包含幫助信息的新頁(yè)面,然后再回到原來(lái)的頁(yè)面,以完成表單的填寫。

          換句話說(shuō),您或者處于“幫助”模式,或者處于“表單填寫”模式。這凸顯了 Web 的兩個(gè)主要的限制:無(wú)態(tài)(即當(dāng)點(diǎn)擊幫助連接時(shí),您在表單中已經(jīng)輸入的信息將會(huì)丟失)和遲延(即您必須等待頁(yè)面裝載)。因此我決定寫一點(diǎn)腳本來(lái)幫助處理這些問(wèn)題。這些腳本通過(guò)動(dòng)態(tài) HTML (DHTML)技術(shù)在您點(diǎn)擊連接時(shí)彈出一個(gè)帶有幫助信息的方框。在我的演示中,就是使用它們來(lái)彈出與表單填寫相關(guān)的上下文幫助信息。這些腳本也可以用在別的地方,比如彈出一篇論文的術(shù)語(yǔ)定義。上述的兩種情況都以合理的方式給出了上下文相關(guān)的信息,即無(wú)模式的方式。同時(shí),這個(gè)解決方案也避免了無(wú)態(tài)和遲延的問(wèn)題。

          實(shí)際上,我寫的這些基本函數(shù)可以用在任何需要在頁(yè)面上移動(dòng)和改變對(duì)象可視性的地方。我做了一個(gè)快速下拉菜單的實(shí)例,就是為了演示同樣這些代碼的另外一種使用方式,您可能會(huì)用得到。

          您可能會(huì)擔(dān)心有人還在使用版本比較老的瀏覽器,對(duì)此,我們可以相當(dāng)輕松地使這些腳本自然地回退到原來(lái)的狀態(tài),使那些使用老版本瀏覽器的用戶可以簡(jiǎn)單地從一個(gè)單獨(dú)的頁(yè)面上獲得信息。我將在下面的“如何使用腳本”的部分中解釋如何實(shí)現(xiàn)這個(gè)目標(biāo)。

          腳本的目標(biāo)

          這個(gè)腳本將創(chuàng)建動(dòng)態(tài)菜單和彈出式對(duì)象。它包括一些跨瀏覽器的基本函數(shù),用于移動(dòng)和改變DHTML對(duì)象的可視性。在 Netscape 4.x 中,一個(gè) DHTML 對(duì)象是一個(gè)通過(guò)絕對(duì)位置定位的 DIV,而對(duì) Safari,Internet Explorer 4 和 5,或者 Netscape 6 來(lái)說(shuō),則是任何 HTML 元素。這些函數(shù)可以被用在大量的 DHTML 應(yīng)用中;這里還給出的兩個(gè)實(shí)例,向您演示如何創(chuàng)建一個(gè)彈出式的提示(tip)和下拉式菜單。腳本中的主要函數(shù)如下:

          • changeObjectVisibility,用來(lái)翻轉(zhuǎn)一個(gè) DHTML 對(duì)象的可視性。
          • moveObject,用來(lái)在瀏覽器窗口中把一個(gè) DHTML 對(duì)象移動(dòng)到特定的位置上。
          • getStyleObject,這個(gè)函數(shù)通過(guò)獲得一個(gè)風(fēng)格對(duì)象的引用簡(jiǎn)化了跨瀏覽器的 DTHML,我們可以從這個(gè)對(duì)象中讀取屬性,或者進(jìn)行屬性設(shè)定,包括位置,可視性,顏色,尺寸,等等。

          編碼的挑戰(zhàn)

          遺憾的是,由于長(zhǎng)期以來(lái)瀏覽器都是由各個(gè)廠商自行實(shí)現(xiàn),所以書(shū)寫跨瀏覽器和跨平臺(tái)的 DHTML 通常是拜占庭式的條件分支。為任何一個(gè)瀏覽器書(shū)寫這些腳本都是非常輕松的;為了使它們工作在 Netscape 4 及其升級(jí)版本,以及工作在 Internet Explorer 4 及其升級(jí)版本上,事情就要復(fù)雜一些了;而使它們可以回退到比較老版本的瀏覽器的狀態(tài),又增加了更多的復(fù)雜度。問(wèn)題在于各個(gè)瀏覽器在如何尋找和操作 Web 頁(yè)面上的對(duì)象方面都有很多獨(dú)特之處,雖然我們對(duì)這種狀態(tài)已經(jīng)比較熟悉了。為了方便,我寫了處理這些條件分支的代碼。

          這些函數(shù)中有一些功能不能工作在更老一些的瀏覽器上,比如 Netscape 3。然而,使這些功能自然地退化并補(bǔ)臺(tái)困難。您只需進(jìn)行如下操作:

          • 直接把這些腳本包含在頁(yè)面上,而不是使用連接的 .js 文件。
          • 只在提供相關(guān)支持的瀏覽器上使用 JavaScript 進(jìn)行彈出式的 DIV 的輸出。實(shí)現(xiàn)這個(gè)控制的代碼大致如下:
            if(document.getElementById || document.all
                || document.layers) {
                // write out div tag with document.write
                }

          我發(fā)現(xiàn)的最大挑戰(zhàn)是必須考慮瀏覽器處理事件的不同方式。事件發(fā)生時(shí)(比如 click 或者 mouseover 事件)光標(biāo)的位置存儲(chǔ)在一個(gè)事件對(duì)象中,而不同瀏覽器對(duì)事件對(duì)象的處理有輕微的不同。當(dāng)事件發(fā)生時(shí),Netscape 4 和6都產(chǎn)生一個(gè)新的事件對(duì)象,您可以把這個(gè)對(duì)象作為一個(gè)參數(shù)傳遞到函數(shù)中;而 Internet Explorer 則使用一個(gè)獨(dú)立的全局 window.event 對(duì)象。對(duì)于這個(gè)問(wèn)題,我在拋棄幾個(gè)現(xiàn)在看來(lái)很草率的解決方案之后,發(fā)現(xiàn)把事件對(duì)象顯式地傳遞給函數(shù)的做法可以適用于這兩種瀏覽器:

          <a href="#" onclick="showPopup('popupName',
          event);">click</a>

          請(qǐng)注意,在事件邊上少了引號(hào)標(biāo)識(shí)。那是因?yàn)樗且粋€(gè)對(duì)象,而不是文本?,F(xiàn)在,在您的函數(shù)中就可以以如下方式使用傳入的事件對(duì)象了:

          function showPopup(nameOfPopup, eventObject) {
          alert(eventObject.clientX);
          }

          一旦把對(duì)象傳遞給函數(shù),您就可以通過(guò)讀取 pageXpageY 屬性(Netscape 4 和 6)或者 clientXclientY 屬性(IE 4+)來(lái)獲得光標(biāo)的位置。然而請(qǐng)注意,clientXclientY 屬性并沒(méi)有考慮頁(yè)面可能被滾動(dòng)的情況,因?yàn)檫@兩個(gè)坐標(biāo)是相對(duì)于窗口的左上角的,而不是整個(gè)文檔。為了解決這個(gè)問(wèn)題,我們加上 IE 的 document.body.scrollLeft document.body.scrollTop 屬性的值。如果您感興趣的話,事件對(duì)象還有一連串有用的屬性,包括一個(gè)事件觸發(fā)對(duì)象的引用(在 IE 上是 srcElement,而在 Netscape 上則是 target)。

          把事件對(duì)象作為參數(shù)進(jìn)行傳遞的唯一麻煩是在不支持事件對(duì)象的老版本瀏覽器上不能工作。為了繞開(kāi)這個(gè)問(wèn)題,我們?cè)?popup.js 文件中包含一個(gè)函數(shù),該函數(shù)為那些不存在事件對(duì)象的瀏覽器創(chuàng)建一個(gè)假的對(duì)象,在裝載文檔時(shí)運(yùn)行:

          function createFakeEventObj() {
          // create a fake event object for older browsers
          //to avoid errors in function call when we
          //need to pass the event object
          if (!window.event) {
          window.event = false;
          }
          }

          這個(gè)函數(shù)把 window.event 設(shè)定為 false(假)。這樣以后,我們就可以在使用之前進(jìn)行檢測(cè),看看是否存在真正的事件對(duì)象。

          在 Mac 版的 Internet Explorer 5 上有一個(gè)問(wèn)題,即當(dāng)彈出層出現(xiàn)在文本的上方時(shí),只有部分內(nèi)容可以被顯示。但是當(dāng)我移動(dòng) DIV 標(biāo)識(shí),使之成為文檔體的第一個(gè)元素時(shí),這個(gè)問(wèn)題神秘地消失了。

          還是在 Mac 版的 IE 5 上,由于某些原因,document.onclick 事件只有在頁(yè)面上存在實(shí)際文本時(shí)才能被觸發(fā)。為了繞過(guò)這個(gè)缺陷(以便使您可以通過(guò)點(diǎn)擊窗口中的任意位置來(lái)關(guān)閉窗口),我在頁(yè)面中增加了一個(gè)不包含任何內(nèi)容的,通過(guò)絕對(duì)位置定位的 DIV,然后用 JavaScript 來(lái)改變這個(gè) DIV 的尺寸,使之覆蓋整個(gè)窗口。相關(guān)的代碼大致如下:

          function resizeBlankDiv() {
          // resize blank placeholder div so IE 5
          // on mac will get all clicks in window
          if ((navigator.appVersion.indexOf('MSIE 5') != -1)
          && (navigator.platform.indexOf('Mac') != -1)
          && getStyleObject('blankDiv')) {
          getStyleObject('blankDiv').width =
          document.body.clientWidth - 20;
          getStyleObject('blankDiv').height =
          document.body.clientHeight - 20;
          }
          }

          遺憾的是,如果瀏覽器的尺寸被改變了,則只有一種方法可以恢復(fù)尺寸,即重新裝載整個(gè)文檔(您可能認(rèn)為,只要用 window.onresize 事件就可以了。然而由于這個(gè)事件在窗口的尺寸真正被改變之前就已經(jīng)發(fā)生了,所以采用這種方法最終會(huì)產(chǎn)生不必要的滾動(dòng)條)。為了恢復(fù)頁(yè)面尺寸,我們又寫了一個(gè)函數(shù),在窗口尺寸被改變的任何時(shí)候,該函數(shù)可以從 Mac 平臺(tái)上的 IE5 的緩存中重新裝載頁(yè)面。

          在 Mac 版的 Internet Explorer 5 上,當(dāng)您點(diǎn)擊一個(gè)連接時(shí),會(huì)出現(xiàn)一個(gè)絕對(duì)大的輪廓,這個(gè)輪廓會(huì)和將要彈出的內(nèi)容相重疊。為了解決這個(gè)問(wèn)題,我在連接上增加了一條風(fēng)格規(guī)則:

          .popupLink { outline: none }

          Netscape 4 在 DIV 的命名上有一些怪異的問(wèn)題。以數(shù)字開(kāi)頭的名稱(比如“1div”),以及有些帶有下劃線的名稱(比如“my_div”)不能轉(zhuǎn)化為層,因此我通常都避免這兩種情況,把我的 DIV 按類似于 myDiv 或者 div1 的形式來(lái)命名。

          Netscape 4 還有一個(gè)嚴(yán)重的缺陷,即當(dāng)窗口的尺寸被改變時(shí),所有的風(fēng)格規(guī)則都會(huì)丟失。我沒(méi)有把修復(fù)這個(gè)缺陷的代碼包含進(jìn)來(lái),因?yàn)橐呀?jīng)有好幾個(gè)這樣的代碼公布出來(lái)了,比如 Webmonke 上的這個(gè).

          最后,在 Netscape 4 中,如果您把 javascript: 放在 hrefs 中,會(huì)導(dǎo)致頁(yè)面的重新裝載,并把函數(shù)的返回值當(dāng)成頁(yè)面的唯一內(nèi)容顯示出來(lái)。因此我們不應(yīng)該采取下面的方式:

          <a href="javascript:myFunction();">clickme</a>

          而必須采取象下面的做法:

          <a href="#" onclick="myFunction();
          return false;">clickme</a>

          實(shí)際上,這也是確保您的腳本在不能運(yùn)行這些函數(shù)的瀏覽器上自然退化的好方法。請(qǐng)注意“return false”這行代碼,它使瀏覽器停止裝載 href 參數(shù)指定的URL。這樣,如果瀏覽器中 JavaScript 被關(guān)閉,或者瀏覽器不能處理 JavaScript,則您可以提供一個(gè)不同的頁(yè)面;但是如果這里的函數(shù)可以運(yùn)行,則連接不會(huì)被打開(kāi)。

          在這個(gè)演示中,我們討論的更深一些:

          <a href="#" onclick="return
          !showPopup('nameFieldPopup', event);">
          clickme</a>

          我們不去深入到所有的細(xì)節(jié),只是大概看看這行代碼,它的意思是運(yùn)行 showPopup 函數(shù),然后返回該函數(shù)返回值的非。那樣,如果 showPopup 返回 true(意思是它成功顯示了彈出層),我們就把 false 返回給連接,這樣連接就不會(huì)改變頁(yè)面。另外一方面,如果 showPopup 返回 false(意思是它不能顯示彈出層),則我們就繼續(xù)執(zhí)行腳本,跟著連接進(jìn)入到一個(gè)獨(dú)立的頁(yè)面,該頁(yè)面具有和彈出層相同的信息。這個(gè)邏輯看起來(lái)可能有點(diǎn)混淆,但是只要記住一條就可以了:如果您返回 false,連接就不起作用了。

          使用腳本

          如果要使用這些腳本來(lái)實(shí)現(xiàn)彈出機(jī)制,請(qǐng)按照如下這些步驟來(lái)進(jìn)行:

          • 如果要進(jìn)行層的彈出,則需要把層工具和實(shí)現(xiàn)彈出機(jī)制的腳本文件都包含進(jìn)您的頁(yè)面。這可以通過(guò)把下面兩條語(yǔ)句包含到您的文檔頭部來(lái)實(shí)現(xiàn):
             <script src="utility.js"></script>
                <script src="popup.js"></script>
          • 確保有可以被彈出的 DIV。這些 DIV 必須被絕對(duì)定位,并且在開(kāi)始是應(yīng)該被隱藏。例如:
            <DIV onclick="event.cancelBubble = true;"
                class=popup id=nameOfPopup>
                Popup text goes here.<br>
                <a href="#" onclick="hideCurrentPopup();
                return false;">
                You can include a link like this to
                close the DIV if you like
                </a>
                </DIV>
            確保在DIV中包含onclick="event.cancelBubble = true;"這行代碼。它告訴JavaScript在您點(diǎn)擊DIV時(shí)不要把點(diǎn)擊事件傳遞給頁(yè)面中的其它對(duì)象。如果省略這行代碼,則彈出層在被點(diǎn)擊時(shí)就會(huì)關(guān)閉(對(duì)于大多數(shù)瀏覽器來(lái)說(shuō)),因?yàn)槲覀円呀?jīng)設(shè)定了一個(gè)關(guān)閉彈出層的事件處理函數(shù)。把這行代碼包含到頁(yè)面中的基本目的是告訴瀏覽器“當(dāng)人們點(diǎn)擊除了彈出層自身(或者打開(kāi)彈出層的原始連接)之外的任何地方時(shí),關(guān)閉彈出層”。
          • 如果要改變彈出層的外觀,請(qǐng)編輯風(fēng)格表單中的.popup的風(fēng)格規(guī)則。
          • 在每一個(gè)應(yīng)該觸發(fā)彈出層的地方調(diào)用showPopup函數(shù),把nameOfPopup改為您希望顯示的彈出層名稱(但是把它放在單引號(hào)中):
            <a 
                onclick="return !showPopup
                ('nameOfPopup', event);">
                clickme</a>
            如果您希望當(dāng)鼠標(biāo)在連接上滾動(dòng)時(shí)出發(fā)彈出層,則只要修改觸發(fā)事件就可以了:
            <a 
                onmouseover="showPopup('nameOfPopup', event);"
                onmouseout="hideCurrentPopup();">clickme
                </a>
          • (可選)修改popup.js文件中的兩個(gè)變量,這兩個(gè)變量用來(lái)控制彈出層出現(xiàn)的位置,該位置是相對(duì)于當(dāng)前光標(biāo)位置的:
            var xOffset = 30;
                var yOffset = -5;

          下面對(duì)相關(guān)的函數(shù)逐一進(jìn)行說(shuō)明:

          • changeObjectVisibility(objectId, newVisibility):調(diào)用這個(gè)函數(shù)時(shí),objectId 應(yīng)該是您希望顯示或者隱藏的對(duì)象名稱。函數(shù)希望這個(gè)參數(shù)是文本類型的,因此您需要把它包含在引號(hào)中。newVisibility 參數(shù)的值或者是 visible(可視)或者是 hidden(隱藏)。再次說(shuō)明一下,這個(gè)值是一個(gè)字符串類型的,因此需要把它包含在引號(hào)中。下面這個(gè)實(shí)例把一個(gè)名為 myBigLayer: 的對(duì)象隱藏起來(lái):
            changeObjectVisibility('myBigLayer', 'hidden')
          • moveObject(objectId, newXCoordinate, newYCoordinate):同樣的,objectId 應(yīng)該是您希望移動(dòng)的對(duì)象名稱。它是一個(gè)文本類型的參數(shù),因此應(yīng)該放在引號(hào)里面。newXCoordinatenewYCoordinate a 是數(shù)字類型的(因此沒(méi)有引號(hào)),描述您希望把對(duì)象移動(dòng)到什么地方。因此,如果要把 myBigLayer 對(duì)象移動(dòng)到距離窗口左邊 300 p 像素,距離窗口上邊10像素的位置,書(shū)寫如下代碼就可以了:
            moveObject('myBigLayer', 300, 10)
          • getStyleObject(objectId):上述兩個(gè)函數(shù)都使用這個(gè)函數(shù)來(lái)把對(duì)象的名稱轉(zhuǎn)變?yōu)閷儆谠搶?duì)象的風(fēng)格對(duì)象的引用。對(duì)于 Netscape 4+ 和 IE 4+ 兩款瀏覽器來(lái)說(shuō),這個(gè)函數(shù)都能返回正確的引用,因此您不必?fù)?dān)心瀏覽器在工作方式上的差別。(請(qǐng)注意:有一種情況在 Netscape 4 上處理不了,那就是聚集層,因此您必須避免把層放到其它層上)。

            在您需要改變對(duì)象的 CSS 屬性的任何時(shí)候,您都可以脫離這里描述的上下文來(lái)使用這個(gè)函數(shù)。例如,假定我們要給 myBigLayer 設(shè)定一個(gè)綠的背景色,可以書(shū)寫如下代碼:

            ar myBigLayerStyleObject =
                getStyleObject('myBigLayer');
                myBigLayerStyleObject.backgroundColor =
                'green';

            Or, for shorthand, you could just do this:

            getStyleObject('myBigLayer').backgroundColor
                = 'green';






            utility.txt

            // Copyright ?2000 by Apple Computer, Inc., All Rights Reserved.
                //
                // You may incorporate this Apple sample code into your own code
                // without restriction. This Apple sample code has been provided "AS IS"
                // and the responsibility for its operation is yours. You may redistribute
                // this code, but you are not permitted to redistribute it as
                // "Apple sample code" after having made changes.
                //
                // ************************
                // layer utility routines *
                // ************************
                function getStyleObject(objectId) {
                // cross-browser function to get an object's style object given its id
                if(document.getElementById && document.getElementById(objectId)) {
                // W3C DOM
                return document.getElementById(objectId).style;
                } else if (document.all && document.all(objectId)) {
                // MSIE 4 DOM
                return document.all(objectId).style;
                } else if (document.layers && document.layers[objectId]) {
                // NN 4 DOM.. note: this won't find nested layers
                return document.layers[objectId];
                } else {
                return false;
                }
                } // getStyleObject
                function changeObjectVisibility(objectId, newVisibility) {
                // get a reference to the cross-browser style object and make sure the object exists
                var styleObject = getStyleObject(objectId);
                if(styleObject) {
                styleObject.visibility = newVisibility;
                return true;
                } else {
                // we couldn't find the object, so we can't change its visibility
                return false;
                }
                } // changeObjectVisibility
                function moveObject(objectId, newXCoordinate, newYCoordinate) {
                // get a reference to the cross-browser style object and make sure the object exists
                var styleObject = getStyleObject(objectId);
                if(styleObject) {
                styleObject.left = newXCoordinate;
                styleObject.top = newYCoordinate;
                return true;
                } else {
                // we couldn't find the object, so we can't very well move it
                return false;
                }
                } // moveObject
                
            popup.txt
            // Copyright ?2000 by Apple Computer, Inc., All Rights Reserved.
                //
                // You may incorporate this Apple sample code into your own code
                // without restriction. This Apple sample code has been provided "AS IS"
                // and the responsibility for its operation is yours. You may redistribute
                // this code, but you are not permitted to redistribute it as
                // "Apple sample code" after having made changes.
                // ********************************
                // application-specific functions *
                // ********************************
                // store variables to control where the popup will appear relative to the cursor position
                // positive numbers are below and to the right of the cursor, negative numbers are above and to the left
                var xOffset = 30;
                var yOffset = -5;
                function showPopup (targetObjectId, eventObj) {
                if(eventObj) {
                // hide any currently-visible popups
                hideCurrentPopup();
                // stop event from bubbling up any farther
                eventObj.cancelBubble = true;
                // move popup div to current cursor position
                // (add scrollTop to account for scrolling for IE)
                var newXCoordinate = (eventObj.pageX)?eventObj.pageX + xOffset:eventObj.x + xOffset + ((document.body.scrollLeft)?document.body.scrollLeft:0);
                var newYCoordinate = (eventObj.pageY)?eventObj.pageY + yOffset:eventObj.y + yOffset + ((document.body.scrollTop)?document.body.scrollTop:0);
                moveObject(targetObjectId, newXCoordinate, newYCoordinate);
                // and make it visible
                if( changeObjectVisibility(targetObjectId, 'visible') ) {
                // if we successfully showed the popup
                // store its Id on a globally-accessible object
                window.currentlyVisiblePopup = targetObjectId;
                return true;
                } else {
                // we couldn't show the popup, boo hoo!
                return false;
                }
                } else {
                // there was no event object, so we won't be able to position anything, so give up
                return false;
                }
                } // showPopup
                function hideCurrentPopup() {
                // note: we've stored the currently-visible popup on the global object window.currentlyVisiblePopup
                if(window.currentlyVisiblePopup) {
                changeObjectVisibility(window.currentlyVisiblePopup, 'hidden');
                window.currentlyVisiblePopup = false;
                }
                } // hideCurrentPopup
                // ***********************
                // hacks and workarounds *
                // ***********************
                // initialize hacks whenever the page loads
                window.onload = initializeHacks;
                // setup an event handler to hide popups for generic clicks on the document
                document.onclick = hideCurrentPopup;
                function initializeHacks() {
                // this ugly little hack resizes a blank div to make sure you can click
                // anywhere in the window for Mac MSIE 5
                if ((navigator.appVersion.indexOf('MSIE 5') != -1)
                && (navigator.platform.indexOf('Mac') != -1)
                && getStyleObject('blankDiv')) {
                window.onresize = explorerMacResizeFix;
                }
                resizeBlankDiv();
                // this next function creates a placeholder object for older browsers
                createFakeEventObj();
                }
                function createFakeEventObj() {
                // create a fake event object for older browsers to avoid errors in function call
                // when we need to pass the event object to functions
                if (!window.event) {
                window.event = false;
                }
                } // createFakeEventObj
                function resizeBlankDiv() {
                // resize blank placeholder div so IE 5 on mac will get all clicks in window
                if ((navigator.appVersion.indexOf('MSIE 5') != -1)
                && (navigator.platform.indexOf('Mac') != -1)
                && getStyleObject('blankDiv')) {
                getStyleObject('blankDiv').width = document.body.clientWidth - 20;
                getStyleObject('blankDiv').height = document.body.clientHeight - 20;
                }
                }
                function explorerMacResizeFix () {
                location.reload(false);
                }
                
            彈出式幫助的實(shí)例

            <HTML><HEAD>

            <script src="utility.txt"></script>

            <script src="popup.txt"></script>


            <STYLE>

            .popupLink { COLOR: red; outline: none }

            .popup { POSITION: absolute; VISIBILITY: hidden; BACKGROUND-COLOR: yellow; LAYER-BACKGROUND-COLOR: yellow; width: 200; BORDER-LEFT: 1px solid black; BORDER-TOP: 1px solid black; BORDER-BOTTOM: 3px solid black; BORDER-RIGHT: 3px solid black; PADDING: 3px; z-index: 10 }

            </STYLE>


            <BODY bgcolor="#ffffff">


            <!-- keep the popup divs as the first things on the page or else MSIE 5 on the mac sometimes has trouble rendering them on top of text -->

            <DIV onclick='event.cancelBubble = true;' class=popup id=nameFieldPopup>Hi, [your name here]! We need to know your <b>name</b> so we can address you a bit more personally. [<a class=closeLink href='#' onclick='hideCurrentPopup(); return false;'>close this tip</a>]</DIV>

            <DIV onclick='event.cancelBubble = true;' class=popup id=emailFieldPopup>Well, yeah, you could put in a fake <b>email address</b>, but then we couldn't send you occasional updates. Oh and, um, we promise not to spam you. [<a class=closeLink href='#' onclick='hideCurrentPopup(); return false;'>close this tip</a>]</DIV>


            <!-- begin body of document -->

            <form>
                <p>Fill in the form:</p>


                <P>Name: <input type=text> [<a href="non_js_help.html" class=popupLink onclick="return !showPopup('nameFieldPopup', event);">help</a>]</P>
                <P>Email: <input type=text> [<a href="non_js_help.html" class=popupLink onclick="return !showPopup('emailFieldPopup', event);">help</a>]</P>
            </form>

             


            <!-- leave this blank div in here to make sure you can click anywhere on the document for MSIE 5 mac -->
            <div id="blankDiv" style="position: absolute; left: 0; top: 0; visibility: hidden"></div>


            </BODY></HTML>
            http://www.apple.com.cn/developer/internet/webcontent/hideshow_layer.html









          posted @ 2008-06-24 17:30 飛飛 閱讀(874) | 評(píng)論 (0)編輯 收藏

             在怎合struts+hibernate+spring時(shí),Tomcat出現(xiàn)了Error Listenerstart錯(cuò)誤碼,郁悶的很,在網(wǎng)上找了很多的資料,提問(wèn)的不少,但都沒(méi)有很標(biāo)準(zhǔn)的解釋以用解決的辦法,有的說(shuō)是jar包的版本沖突,有的說(shuō)是Tomcat的自身問(wèn)題,各解釋都有,基本上所有的方法我都試過(guò)了。就這個(gè)問(wèn)題搞了兩天。終于找到了解決的辦法:在web.xml時(shí)將:

          <!-- 使用監(jiān)聽(tīng)方式載入Spring上下文 -->
          <listener>
             <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
          </listener>

          改為:

          <!-- 使用監(jiān)聽(tīng)方式載入Spring上下文 -->
          <servlet>
             <servlet-name>SpringContextServlet</servlet-name>
             <servlet-class>
              org.springframework.web.context.ContextLoaderServlet
             </servlet-class>
             <load-on-startup>1</load-on-startup>
          </servlet>
          <servlet>
             <servlet-name>SpringLog4jConfigServlet</servlet-name>
             <servlet-class>
              org.springframework.web.util.Log4jConfigServlet
             </servlet-class>
          </servlet>
          <servlet>
             <servlet-name>web</servlet-name>
             <servlet-class>
              org.springframework.web.servlet.DispatcherServlet
             </servlet-class>
          </servlet>

          posted @ 2008-06-22 11:46 飛飛 閱讀(7575) | 評(píng)論 (1)編輯 收藏

          一、在Myeclipse軟件中部署

          1、 Myeclipse中,創(chuàng)建好工程后,在Myeclipse菜單欄中選擇 Windows -> Preferences -> Myeclipse -> Tomcat5,選擇"Enable";Tomact Home Directory要選擇你機(jī)器上Tomcat所安裝的目錄。然后,再Windows -> Preferences -> Myeclipse -> Tomcat5 ->JDK,確保這個(gè)是有對(duì)應(yīng)的jdk版本,若沒(méi)有,則通過(guò)"Add"添加其安裝路徑。ok

          2、選擇工具欄上的 按鈕,在”Project”中選擇你要部署的工程,然后”Add”,再選擇”Tomcat”,Finish。

          3、 在工具欄上選擇 ,啟動(dòng)Tomcat。

          4、 運(yùn)行程序。在IE中輸入http://localhost:8080/aa/WebRoot/index.jsp(aa為工程名字)

          二、在Tomcatserver.xml配置文件中部署

          1、在Tomcat下,找到conf文件下的server.xml,打開(kāi)。

          2、在<Host></host>之間加上如下代碼:

          1 
          2 <Context path="/虛擬目錄名" docBase="目標(biāo)目錄位置" debug="0" reloadable="true" >
          3 </Context>

          (嚴(yán)格區(qū)分大小寫,當(dāng)path=""時(shí),此時(shí)的虛擬目錄直接為root--->http://localhost:8080/)
                 
          參數(shù):

                   path:表示在瀏覽器中輸入http://localhost:8080/虛擬目錄名

                   docBase:表示你的程序包的物理絕對(duì)路徑,默認(rèn)的絕對(duì)路徑是     %tomcat_home%/webapps

                   reloadable :為true,則tomcat會(huì)自動(dòng)檢測(cè)應(yīng)用程序的/WEB-INF/lib /WEB-INF/classes目錄的變化,自動(dòng)裝載新的應(yīng)用程序,我們可以在不重起tomcat的情況下改變應(yīng)用程序;為false則不自動(dòng)加載。

           (我覺(jué)得這種部署方法就好在這里,可以不用重新啟動(dòng)Tomcat。不知道前一種方法是不是在哪個(gè)地方進(jìn)行配置即可實(shí)現(xiàn)同樣的效果。若有,請(qǐng)高人指點(diǎn)?。?/span>

          示例:

          1        
          2 <!-- 我的自定義目錄-->
          3 <Context path="/wess" debug="0" docBase="C:\Documents and Settings\tt\workspace\Welcome_SS\WebRoot" reloadable="true">
          4 </Context> 
          5 4

          3、 啟動(dòng)Tomcat

          Myeclipse工具欄上選擇 ,啟動(dòng)Tomcat?;蛘咴?/span>Tomcat下,找到bin文件下的startup.bat,打開(kāi)進(jìn)行啟動(dòng)。

          4、 運(yùn)行程序。在IE地址中輸入http://localhost/wess/index.jsp(引用上面示例配置時(shí)的情況)

          附:

              在lib下的struts-config.xml可以添加下面三句進(jìn)行主頁(yè)默認(rèn)的配置,即在IE中只需輸入到主頁(yè)所在目錄,而不必寫出主頁(yè)。如上面的配置就可只輸入http://localhost/wess

           <welcome-file-list>
          <welcome-file>index.jsp</welcome-file>
          </welcome-file-list>

           

          posted @ 2008-06-22 09:07 飛飛 閱讀(399) | 評(píng)論 (1)編輯 收藏

          僅列出標(biāo)題
          共12頁(yè): First 上一頁(yè) 4 5 6 7 8 9 10 11 12 下一頁(yè) 
          主站蜘蛛池模板: 大田县| 吉林市| 青川县| 宜兰市| 宣恩县| 永善县| 黄山市| 夹江县| 望都县| 寿光市| 虞城县| 盐城市| 阜新市| 酉阳| 寻乌县| 泌阳县| 江阴市| 华宁县| 湄潭县| 石狮市| 禄劝| 巴南区| 肃北| 栾川县| 布尔津县| 马关县| 怀仁县| 甘谷县| 平邑县| 汶川县| 北辰区| 阳谷县| 紫金县| 河北省| 乌鲁木齐县| 彩票| 五原县| 新民市| 包头市| 莆田市| 南汇区|