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

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

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

    all gone

    all gone

    2005年12月9日 #

    Ubuntu UTF8環境下搭建中文LaTeX環境

    1. 基本包的安裝
    sudo apt-get install tetex-base tetex-bin tetex-extra
    1. CJK包安裝
    sudo apt-get install latex-cjk-chinese
    1. CJK UTF8字體生成
    將下面的code復制到文件cvtfont.sh中:

    #!/bin/sh
    #
    # Origin By Edward G.J. Lee
    2001.11.25
    # http:
    //www.study-area.org/tips/latex/pdftex.html
    # This code is Public Domain.
    #
    # Enhanced by intron@intron.ac,
    2006.1.9
    # Modified
    for NetBSD by jungle@soforge.com, 2006.1.14
    # Italic support added by robert.zhangle@gmail.com,
    2006.5.19
    #

    if [ $# -ne 3 ]
    then

    cat
    << EOF
    Usage: `basename $
    0` font.ttf <TeX_Internal_Font_Name> <Tex_Font_Name>
    <TeX_Internal_Font_Name>: Used to name *.enc, *.afm, *.pfb, *.tfm & *.map
    <Tex_Font_Name>: Used in TeX source: \\CJKencfamily{UTF8}{Tex_Font_Name}

    An example: `basename $
    0` gbsn00lp.ttf gbsn00lp songpt1

    EOF

    exit
    1
    fi

    if ! which ttf2pt1; then
    echo
    "Please install pkgsrc fonts/ttf2pt1 before you can run me."
    exit
    1
    fi

    if ! which t1asm; then
    echo
    "Please install pkgsrc fonts/t1utils before you can run me."
    exit
    1
    fi

    if ! which extconv; then
    echo
    "Please install pkgsrc chinese/CJK before you can run me."
    exit
    1
    fi


    cat
    <<EOF
    ***************************************************************************
    * Please confirm that current working directory is EMPTY except scripts *
    * and HAS ENOUGH SPACE to contain so many intermediate files. *
    * If it is not empty, this script may DAMAGE INNOCENT FILES!!! *
    ***************************************************************************
    EOF

    read
    -p "Go ahead?[n]" a

    if [ "$a" != "y" ] && [ "$a" != "Y" ]; then
    exit
    0
    fi

    FONTFILENAME
    ="$1"
    FONTNAME
    ="$2"
    FONTTEXNAME
    ="$3"

    #TEXMFHOME
    =`kpsexpand '$TEXMFHOME'`
    TEXMFMAIN
    =`kpsexpand '$TEXMFMAIN'`
    TEXMFHOME
    ='/usr/share/texmf-tetex/'
    TTFONTFILEDIR
    =${TEXMFHOME}/fonts/truetype/chinese/
    ENCDIR
    =${TEXMFHOME}/fonts/enc/dvips/chinese/${FONTNAME}
    AFMDIR
    =${TEXMFHOME}/fonts/afm/chinese/${FONTNAME}
    TFMDIR
    =${TEXMFHOME}/fonts/tfm/chinese/${FONTNAME}
    PFBDIR
    =${TEXMFHOME}/fonts/type1/chinese/${FONTNAME}
    MAPDIR
    =${TEXMFHOME}/fonts/map/dvips/chinese

    UPDMAPCFG
    =${TEXMFHOME}/web2c/updmap.cfg

    if [ ! -f $UPDMAPCFG ]
    then
    SYSUPDMAPCFG
    =`kpsewhich -format 'web2c files' updmap.cfg`
    cp $SYSUPDMAPCFG $UPDMAPCFG
    fi

    CIDXMAP
    =${TEXMFHOME}/dvipdfm/config/cid-x.map

    if [ ! -f $CIDXMAP ]
    then
    touch $CIDXMAP
    fi

    CJKDIR
    =${TEXMFMAIN}/tex/latex/CJK/UTF8

    INSTALLDIRMODE
    ="-m 0755"
    INSTALLMODE
    ="-m 0644"

    FONTFILEBASENAME
    =`basename "$FONTFILENAME"`
    FDNAME
    =c70${FONTTEXNAME}.fd

    #MAPFILE
    =/usr/local/share/ttf2pt1/maps/cugb.map
    PLANENUM
    =255

    # Initialize ${FONTNAME}.map
    echo
    -n "" > ${FONTNAME}.map


    n
    =0

    echo
    "Generating subfonts from plane $n to plane $PLANENUM ..."

    while [ $n -le $PLANENUM ]
    do
    m
    =`printf %02x $n`

    echo
    -n "[$n]"

    SUBFONTNAME
    =${FONTNAME}${m}

    # Generate
    *.t1a *.afm *.enc
    ttf2pt1
    -GAE -pft -OHUBs -W0 -l plane+pid=3,eid=1,0x$m \\
    "$FONTFILENAME" ${SUBFONTNAME}

    # avoid dvips(k)(before v5.
    86) t1part module bug.
    perl
    -pi -e 's/_/Z/g' ${SUBFONTNAME}.t1a ${SUBFONTNAME}.afm

    # Generate
    *.pfb
    t1asm
    -b ${SUBFONTNAME}.t1a > ${SUBFONTNAME}.pfb 2>/dev/null

    # Generate
    *.tfm
    afm2tfm ${FONTNAME}$m.afm ${FONTNAME}$m.tfm
    >/dev/null
    afm2tfm ${FONTNAME}$m.afm
    -s .167 ${FONTNAME}sl$m.tfm >/dev/null

    # Generate ${FONTNAME}.map
    AFMNAME
    =`grep -m 1 -i fontname ${SUBFONTNAME}.afm | cut -d ' ' -f 2`
    echo
    "${FONTNAME}$m ${AFMNAME} <${FONTNAME}$m.pfb" >> ${FONTNAME}.map
    echo
    "${FONTNAME}sl$m ${AFMNAME} \\" .167 SlantFont \\" <${FONTNAME}$m.pfb" \\
    >> ${FONTNAME}.map

    n
    =`expr $n + 1`
    done

    echo

    cat
    > ${FDNAME} << EOF
    % This file is automatically generated by `basename $0`
    \\\\def\\\\fileversion{
    0.0.1}
    \\\\def\\\\filedate{`date
    +%Y/%m/%d`}
    \\\\ProvidesFile{${FDNAME}}[\\\\filedate\\\\space\\\\fileversion]

    \\\\DeclareFontFamily{C70}{${FONTTEXNAME}}{\\\\hyphenchar \\\\font\\\\m@ne}

    \\\\DeclareFontShape{C70}{${FONTTEXNAME}}{m}{n}{
    <-> CJK * ${FONTNAME}}{}
    \\\\DeclareFontShape{C70}{${FONTTEXNAME}}{bx}{n}{
    <-> CJKb * ${FONTNAME}}{\\\\CJKbold}
    \\\\DeclareFontShape{C70}{${FONTTEXNAME}}{m}{it}{
    <-> CJK * ${FONTNAME}sl}{}
    \\\\DeclareFontShape{C70}{${FONTTEXNAME}}{bx}{it}{
    <-> CJKb * ${FONTNAME}sl}{\\\\CJKbold}
    \\\\DeclareFontShape{C70}{${FONTTEXNAME}}{m}{sl}{
    <-> CJK * ${FONTNAME}sl}{}
    \\\\DeclareFontShape{C70}{${FONTTEXNAME}}{bx}{sl}{
    <-> CJKb * ${FONTNAME}sl}{\\\\CJKbold}

    \\\\endinput
    EOF


    #exit
    0;

    echo
    echo
    "Installing ..."

    install
    -d $INSTALLDIRMODE $TTFONTFILEDIR $ENCDIR $AFMDIR $TFMDIR $PFBDIR $MAPDIR $CJKDIR

    install $INSTALLMODE $FONTFILENAME $TTFONTFILEDIR

    n
    =0
    while [ $n -le $PLANENUM ]
    do
    m
    =`printf %02x $n`
    echo
    -n "[$n]"

    install $INSTALLMODE ${FONTNAME}${m}.enc $ENCDIR
    install $INSTALLMODE ${FONTNAME}${m}.afm $AFMDIR
    install $INSTALLMODE ${FONTNAME}${m}.tfm $TFMDIR
    install $INSTALLMODE ${FONTNAME}sl${m}.tfm $TFMDIR
    install $INSTALLMODE ${FONTNAME}${m}.pfb $PFBDIR

    n
    =`expr $n + 1`
    done

    echo

    install $INSTALLMODE ${FONTNAME}.map $MAPDIR
    install $INSTALLMODE $FDNAME $CJKDIR

    echo
    >> $UPDMAPCFG
    echo
    "Map ${FONTNAME}.map" >> $UPDMAPCFG

    # update cid
    -x.map

    echo
    "${FONTNAME}@Unicode@ unicode :0:${FONTFILENAME}" >> $CIDXMAP
    echo
    "${FONTNAME}sl@Unicode@ unicode :0:${FONTFILENAME}" >> $CIDXMAP

    mktexlsr

    #updmap
    -sys
    updmap

    read
    -p "Do you want remove all intermediate files?[n]" a
    if [ "$a" = "y" ] || [ "$a" = "Y" ]; then

    n
    =0
    while [ $n -le $PLANENUM ]
    do
    m
    =`printf %02x $n`
    echo
    -n "[$n]"

    rm
    -f ${FONTNAME}${m}.enc ${FONTNAME}${m}.afm ${FONTNAME}${m}.t1a \\
    ${FONTNAME}${m}.pfb ${FONTNAME}sl${m}.tfm ${FONTNAME}${m}.tfm

    n
    =`expr $n + 1`
    done

    echo

    rm
    -fv $FDNAME ${FONTNAME}.map
    fi

    echo
    echo
    "OK, all done. :-)"
    echo


    根據自己的需要可以將TEXMFHOME目錄設置成不同的地方,只要Latex能找到即可
    我將該目錄改為了/usr/share/texmf-tetex,如果相應的目錄不存在,則需要自己新建。


    將windows系統中的字體文件拷到腳本所在目錄執行腳本即可生成Latex所需字體文件,以simhei.ttf為例:

    sudo ./cvtfont.sh simhei.ttf simhei simhei







    posted @ 2007-05-16 13:34 all gone 閱讀(1123) | 評論 (0)編輯 收藏

    Struts2 入門

         摘要: 很久沒有看Java相關的東西了,這幾天才發現Struts2 已經發布了,以前就聽說Struts2就是以前的Webwork2,只是作了少許的改動而已,我以前也沒看過Webwork,所以趕緊下來試了一把。Struts2的地址:http://struts.apache.org/2.x在Eclipse中新建了一個Tomcat工程(如果用WTP插件的話Dynamic Web工程)struts2Test,以下...  閱讀全文

    posted @ 2007-01-08 21:59 all gone 閱讀(8482) | 評論 (8)編輯 收藏

    Ubuntu下NVIDIA驅動的問題

    前幾天按照Ubuntu How-To上的NVIDIA驅動安裝說明安裝了8672版的驅動,結果發現只要退出X-Window,系統就會沒有反應,網上搜了搜,發現有人也有一樣的情況,按照說明重新安裝、重新配置Xorg,問題依然沒有解決,X-Window也起不來了。

    到NVIDIA網站上下了最新的8774版驅動后,趕緊找找看怎么自己裝,有人已經寫好了
    在恢復模式下:
    需要gcc支持,如果沒有安裝則:
    apt-get install build-essential gcc
    刪除已經安裝的NVIDIA驅動:
    apt-get --purge remove linux-restricted-modules-`uname -r` linux-restricted-modules-common nvidia-glx nvidia-settings nvidia-kernel-common
    安裝內核headers
    apt-get install linux-headers-`uname -r`
    將下載下來的NVIDIA-Linux-x86-1.0-8774-pkg1.run解壓縮:
    sh ./NVIDIA-Linux-x86-1.0-8774-pkg1.run --extract-only
    進入解壓后的NVIDIA-Linux-x86-1.0-8774-pkg1文件夾,執行安裝:
    ./nvidia-installer -n --x-prefix=/usr/lib/xorg/
    最后由于默認安裝到了/usr/lib/xorg/lig/xorg,需要將文件拷到對應的目錄下:
    cp --no-dereference /usr/lib/xorg/lib/xorg/libX* /usr/lib/xorg/modules/

    cp /usr/lib/xorg/lib/xorg/modules/drivers/* /usr/lib/xorg/modules/drivers/

    cp --no-dereference /usr/lib/xorg/lib/xorg/modules/extensions/* /usr/lib/xorg/modules/extensions/

    posted @ 2006-09-22 15:42 all gone 閱讀(1048) | 評論 (0)編輯 收藏

    Qt 4下連接MySQL數據庫

    前天剛裝了個Qt4for windows,發現安裝的時候MySQL等數據庫插件都沒有安裝,像Qt X11版一樣,都需要自己安裝這些插件。

    在Qt的安裝目錄C:\Qt4.1.2\下,有個src目錄,進入plugins\sqldrivers\mysql,可以看到兩個文件,main.cpp和mysql.pro,很顯然要用qmake來完成編譯、生成目標。

    編譯前,首先保證依賴的MySQL頭文件和庫文件正確。首先MySQL安裝目錄下的include中的所有文件拷到qmake時能找到的目錄下,接著從lib/opt目錄下拷出libmysql.a,其實lib/opt下只有libmysql.lib和libmysql.dll,從網上搜了一下找到一個方法從libmysql.dll生成libmysql.a:

    1 、安裝好MySQL (如果不愿意安裝,找個libmySQL.dll文件也可以)

    2、下載Pexports工具

    3、轉換操作: pexports libmysql.dll > libmysql.def

    4、使用MinGW的 dlltool轉換成為libmysql.a文件。dlltool --input-def libmysql.def --dllname libmysql.dll --output-lib libmysql.a -k

    5、嘗試是否成功:
    將生成的libmysql.a 拷到qmake的lib搜索路徑下后在plugins\sqldrivers\mysql目錄下做:
    qmake -project
    qmake
    make

    如果再出現象mysql_connect@xx (xx是數字)的錯誤提示。就執行第6步。

    6、修改libmysql.def文件,給mysql_connect加上@xx,即mysql_connect@xx

    7、重做第4步

    8、然后嘗試第5步,如果還是出現錯誤提示。就作第6步。一直到沒有錯誤為止。

    最后C:\Qt4.1.2\plugins\sqldrivers下將會生成需要的libqsqlmysql.a和qsqlmysql.dll。

    找了一個測試文件,通過。
    #include?<QtSql>?
    #include?<QtGui>?


    bool?createConnection(){?
    QSqlDatabase?db?
    =?QSqlDatabase::addDatabase("QMYSQL");?
    db.setHostName("localhost");?
    db.setDatabaseName("test");?
    db.setUserName("test");?
    db.setPassword("");?

    if(!db.open()){?
    QMessageBox::critical(
    0,?QObject::tr("Database?Error"),?
    ??????????????????????????????db.lastError().text())
    ;?

    return?false
    ;?
    }?

    QSqlQuery?query
    ;?
    //query.exec("insert?into?book?values(?3,?'title',?'author')?");?
    query.exec("select?title?,?author?from?book?");?

    while?(query.next())?{?


    ????QString?title?
    =?query.value(0).toString();?
    ????QString?author?=?query.value(1).toString();?

    QMessageBox::critical(
    0,?title,author);?
    ????
    }?


    return?true
    ;?
    }?



    int?main(int?argc
    ,char**?argv){?

    QApplication?app(argc
    ,?argv);?
    ????if?(!createConnection()){?

    return?
    1;?
    }?
    ????????

    ????return?app.exec()
    ;?


    }?

    posted @ 2006-08-28 20:57 all gone 閱讀(2735) | 評論 (0)編輯 收藏

    EJB3.0 + Struts小試

         摘要: 一直想做一個 EJB3.0 結合 Struts 的例子,前天剛好從網上找到了一個相關的 Tutorial ,于是小試了一把,雖然只是完成了 Tutorial 上的一小點功能,但是感覺還是有必要寫下來,免得以后還要再去看別人的Tutorial 。 開發環境:?? ??? Eclipse3.2 + WTP1.5 , JBoss 4.0.3SP1 , jboss-EJB-3.0_RC...  閱讀全文

    posted @ 2006-08-11 13:52 all gone 閱讀(3065) | 評論 (0)編輯 收藏

    SSH(Spring + Struts + Hibernate)小試 之三

    SSH(Spring + Struts + Hibernate)小試 之三


    前面通過PlugIn我們實現了Spring Context的加載,不過僅僅加載Context并沒有什么實際
    意義,我們還需要修改配置,將Struts Action交給Spring容器進行管理。下面將通過一個Regsit
    實例加以說明。

    首先準備好regist.jsp和login.jsp,在regist.jsp中 的form有name,password,password2,email域。

    在struts-config.xml中添加配置:

    <form-bean name="registForm" type="com.lzy.forum.form.RegistForm" />

    <action path="/regist" name="registForm"
    type="org.springframework.web.struts.DelegatingActionProxy"

    validate="true" input="/regist.jsp" scope="request">
    <forward name="failure" path="/regist.jsp" />
    <forward name="success" path="/login.jsp" />
    </action>


    RegistForm,RegistAction按照原來Struts的方法去寫,我在RegistAction中加入了一個UserDAO對象
    userDAO,這個對象由Spring注入。

    <bean name="/regist" class="com.lzy.forum.action.RegistAction"
    singleton="false">
    <property name="userDAO">
    <ref local="userDAO" />
    </property>
    </bean>

    基本上SSH的架構已經完成,經確認后可以自己測試一下了。(完)

    posted @ 2006-07-18 16:41 all gone 閱讀(647) | 評論 (1)編輯 收藏

    SSH(Spring + Struts + Hibernate)小試 之二

    Spring和Struts結合有幾種方法,我選了最常用的PlugIn方式,在struts-config.xml中加入

    <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
    ??????<set-property property="contextConfigLocation"
    ?????????? ?value="/WEB-INF/action-servlet.xml" />
    ?</plug-in>

    WEB-INF目錄下的action-servlet.xml就是Spring的配置文件,下面給出的是整個的action-servlet.xml文件:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING/DTD BEAN/EN" "<beans>

    //Data Source

    ?<bean id="dataSource"
    ??class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    ??<property name="driverClassName">
    ???<value>com.mysql.jdbc.Driver</value>
    ??</property>
    ??<property name="url">
    ???<value>jdbc:mysql://localhost:3306/forum</value>
    ??</property>
    ??<property name="username">
    ???<value>test</value>
    ??</property>
    ??<property name="password">
    ???<null />
    ??</property>
    ?</bean>

    // For Hibernate
    ?<bean id="sessionFactory"
    ??class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    ??<property name="dataSource">
    ???<ref local="dataSource" />
    ??</property>
    ??<property name="mappingResources">
    ???<list>
    ????<value>com/lzy/forum/domain/User.hbm.xml</value>
    ????<value>com/lzy/forum/domain/Article.hbm.xml</value>
    ????<value>com/lzy/forum/domain/Board.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>

    ?

    // For DAO
    ?<bean id="userDAO"
    ??class="com.lzy.forum.dao.impl.UserDAOHibernate">
    ??<property name="sessionFactory">
    ???<ref local="sessionFactory" />
    ??</property>
    ?</bean>

    ?

    ?<bean id="boardDAO"
    ??class="com.lzy.forum.dao.impl.BoardDAOHibernate">
    ??<property name="sessionFactory">
    ???<ref local="sessionFactory" />
    ??</property>
    ?</bean>

    ?<bean id="articleDAO"
    ??class="com.lzy.forum.dao.impl.ArticleDAOHibernate">
    ??<property name="sessionFactory">
    ???<ref local="sessionFactory" />
    ??</property>
    ?</bean>

    //For Struts Action

    ?<bean name="/regist" class="com.lzy.forum.action.RegistAction"
    ??singleton="false">
    ??<property name="userDAO">
    ???<ref local="userDAO" />
    ??</property>

    ?</bean>


    ?<bean name="/login" class="com.lzy.forum.action.LoginAction"
    ??singleton="false">
    ??<property name="userDAO">
    ???<ref local="userDAO" />
    ??</property>

    ?</bean>

    ?<bean name="/boardManage"
    ??class="com.lzy.forum.action.BoardManageAction" singleton="false">
    ??<property name="userDAO">
    ???<ref local="userDAO" />
    ??</property>
    ??<property name="boardDAO">
    ???<ref local="boardDAO" />
    ??</property>

    ?</bean>

    ?<bean name="/boardNavigate"
    ??class="com.lzy.forum.action.BoardNavigateAction" singleton="false">
    ??<property name="boardDAO">
    ???<ref local="boardDAO" />
    ??</property>

    ?</bean>

    ?<bean name="/boardDisplay"
    ??class="com.lzy.forum.action.BoardDisplayAction" singleton="false">
    ??<property name="boardDAO">
    ???<ref local="boardDAO" />
    ??</property>

    ?</bean>

    ?<bean name="/articleManage"
    ??class="com.lzy.forum.action.ArticleManageAction" singleton="false">
    ??<property name="userDAO">
    ???<ref local="userDAO" />
    ??</property>
    ??<property name="boardDAO">
    ???<ref local="boardDAO" />
    ??</property>
    ??<property name="articleDAO">
    ???<ref local="articleDAO" />
    ??</property>


    ?</bean>


    </beans>

    經過這樣的配置之后,Hibernate事務交由Spring管理,sessionFactory從Spring容器獲得。下面通過其中的一個DAO實例來看看這樣做帶來的方便。


    //BoardDAO.java

    package com.lzy.forum.dao;

    import java.util.ArrayList;

    import com.lzy.forum.domain.Board;

    public interface BoardDAO {
    ?
    ?public boolean isBoardExist(String name);
    ?
    ?public void addBoard(Board board);
    ?
    ?public void deleteBoard(Board board);
    ?
    ?public Board loadBoard(int id);
    ?
    ?public Board loadBoard(String name);
    ?
    ?public Board loadBoardWithArticles(int id);
    ?
    ?public ArrayList getRootBoardsList();
    ?
    ?
    ?
    }


    //BoardDAOHibernate.java

    package com.lzy.forum.dao.impl;

    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.ListIterator;
    import java.util.Set;

    import org.hibernate.Hibernate;
    import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

    import com.lzy.forum.dao.BoardDAO;
    import com.lzy.forum.domain.Board;

    public class BoardDAOHibernate extends HibernateDaoSupport implements BoardDAO {

    ?public void deleteBoard(Board board) {
    ??// TODO Auto-generated method stub
    ??this.getHibernateTemplate().delete(board);
    ?}

    ?public void addBoard(Board board) {
    ??// TODO Auto-generated method stub
    ??this.getHibernateTemplate().saveOrUpdate(board);

    ?}

    ?public boolean isBoardExist(String name) {
    ??// TODO Auto-generated method stub
    ??ArrayList list = (ArrayList) this.getHibernateTemplate().find(
    ????"from Board where name = ? ", new Object[] { name });
    ??if (list.size() > 0) {
    ???// System.out.println("find it");
    ???return true;
    ??}
    ??return false;
    ?}

    ?public Board loadBoard(int id) {
    ??// TODO Auto-generated method stub
    ??ArrayList list = (ArrayList) this.getHibernateTemplate().find(
    ????"from Board where id = ? ", new Object[] { id });

    ??Board b = null;
    ??if (list.size() > 0) {
    ???b = (Board) list.get(0);
    ??}

    ??return b;
    ?}

    ?public Board loadBoard(String name) {
    ??// TODO Auto-generated method stub
    ??ArrayList list = (ArrayList) this.getHibernateTemplate().find(
    ????"from Board where name = ? ", new Object[] { name });

    ??Board b = null;
    ??if (list.size() > 0) {
    ???b = (Board) list.get(0);
    ??}

    ??return b;
    ?}

    ?public ArrayList getRootBoardsList() {
    ??// TODO Auto-generated method stub
    ??ArrayList list = (ArrayList) this.getHibernateTemplate().find(
    ????"from Board b left join fetch b.ChildBoards where b.Parent = null order by b.id");
    ??System.out.println(list.size() + " root boards found ");
    ??

    ??ListIterator index = list.listIterator();
    ??while (index.hasNext()) {

    ???Board s = (Board) index.next();
    ???//this.getSession(true);
    ???//Hibernate.initialize(s.getChildBoards());
    ???///*
    ??? Set children? = (Set) s.getChildBoards();
    ??? Iterator it = children.iterator();
    ???
    ??? while(it.hasNext()){
    ??? Board b = (Board)it.next();
    ??? //Hibernate.initialize(b);
    ??? System.out.println(b.getName());
    ??? }
    ??? //*/

    ???//System.out.println(children.size() + "child(ren) found ");
    ???//s.setChildBoards(s.getChildBoards());
    ??}

    ??return list;
    ?}

    ?public Board loadBoardWithArticles(int id) {
    ??// TODO Auto-generated method stub
    ??ArrayList list = (ArrayList) this.getHibernateTemplate().find(
    ????"from Board b left join fetch b.Articles where b.Id = ? ", new Object[] { id });

    ??Board b = null;
    ??if (list.size() > 0) {
    ???b = (Board) list.get(0);
    ??}

    ??return b;

    ?}


    }


    BoardDAOHibernate繼承 HibernateDaoSupport后,通過getHibernateTemplate()得到一個HibernateTemplate實例,然后執行CRUD操作,非常簡單。需要注意的是,由于執行一次CRUD操作后,Hibernate session關閉,如果有使用延遲加載策略的對象沒有加載,在后面的Web層很容易出現如下錯誤:
    failed to lazily initialize a collection of role
    從網上搜到的解決方法是Open Session In View,
    <filter>
    ???? <filter-name>hibernateFilter</filter-name>
    ???? <filter-class> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
    ???? </filter-class>

    ???? <!-- singleSession默認為true,若設為false則等于沒用OpenSessionInView -->
    ??? <init-param>
    ?????? <param-name>singleSession</param-name>
    ?????? <param-value>true</param-value>
    ??? </init-param>
    ? </filter>

    ?? <filter-mapping>
    ???? <filter-name>hibernateFilter</filter-name>
    ???? <url-pattern>*.do</url-pattern>
    ?? </filter-mapping>
    我試了試,還是有一些問題,所以后來還是放棄了這種方法,所有在Web層中需要的對象都必須在Business層中加載完成。如下面的代碼所示:

    ArrayList list = (ArrayList) this.getHibernateTemplate().find(
    ????"from Board b left join fetch b.Articles where b.Id = ? ", new Object[] { id });


    這樣Hibernate和Spring的結合也算完成了。其他的一些DAO類和實現代碼我沒有給出,但是大同小異,和Board的實現類似。


    最后將是Struts 和Spring的結合,將在下一篇給出。(未完待續)





    posted @ 2006-07-18 16:09 all gone 閱讀(950) | 評論 (0)編輯 收藏

    SSH(Spring + Struts + Hibernate)小試 之一

    之前對Spring Struts Hibernate都稍有了解,Spring的IOC給我留下了很深的印象,容器管理的對象生成
    方法極大地簡化了程序邏輯,Spring也提供了用于Web的Spring MVC 框架,由于我感覺其易用性還是不及
    Struts,所以我還是選擇Struts作為前端WEB框架,Hibernate我一直沒有在Web應用中試過,這次當然不會
    錯過機會了。


    開發環境的塔建我就不多說了,具體可以參考我以前的幾篇日志。

    在Eclipse中新建一個動態Web工程,將Struts 、Spring、Hibernate需要的jar都添加到WEB-INF/lib目錄下,
    將Struts標簽所需的tld文件、struts-config.xml文件(可以由StrutsIDE生成)添加到WEB-INF下,另外在
    此目錄下添加一個Spring的配置文件applicationContext.xml。


    我參考的例子是夏昕的《深入淺出Hibernate》上的第6章,很好的一個論壇示例。

    首先按照書上的ER模型,在數據庫(MySQL)中建立相應的數據庫。


    create database forum;

    use forum;

    create table user(
    ?id int not null auto_increment primary key,
    ?name varchar(50),
    ?pwd varchar(50),
    ?email varchar(50)

    )type=innodb;


    create table board(
    ?id int not null auto_increment primary key,?
    ?parent_id int,
    ?create_by int not null,
    ?name varchar(50) not null,
    ?remark varchar(255),
    ?create_time datetime,

    ?index(parent_id),
    ?index(create_by),

    ?foreign key(parent_id) references board(id) on delete cascade,
    ?foreign key(create_by) references user(id) on delete no action
    ?
    )type=innodb;


    create table article(
    ?id int not null auto_increment primary key,?
    ?parent_id int ,
    ?board_id int not null,
    ?article_type int not null,
    ?title varchar(255),
    ?body text,
    ?create_by int not null,

    ?create_time datetime,
    ?hits int unsigned,
    ?bytes int unsigned,
    ?last_update_by int not null,
    ?last_update_time datetime,

    ?index(parent_id),
    ?index(board_id),
    ?index(create_by),
    ?index(last_update_by),

    ?foreign key(parent_id) references article(id) on delete no action,
    ?foreign key(board_id) references board(id) on delete cascade,
    ?foreign key(create_by) references user(id) on delete no action,
    ?foreign key(last_update_by) references user(id) on delete no action
    ?
    )type=innodb;

    之后,我選擇了用Hibernate Sychonizer來生成映射文件和實體類,然后對生成的類進行修改(刪掉了生成的Base類),
    實際上Hibernate Sychonizer生成的映射文件也有錯誤,需要修改,我也是后來在使用中發現的。

    //User.hbm.xml

    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC
    ?"-//Hibernate/Hibernate Mapping DTD//EN"
    ?"
    http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd " >

    <hibernate-mapping package="com.lzy.forum.domain">
    ?<class
    ??name="User"
    ??table="user"
    ?>

    ??<id
    ???name="Id"
    ???type="integer"
    ???column="id"
    ??>
    ???<generator class="native"/>
    ??</id>

    ??<property
    ???name="Name"
    ???column="name"
    ???type="string"
    ???not-null="false"
    ???length="50"
    ??/>
    ??<property
    ???name="Pwd"
    ???column="pwd"
    ???type="string"
    ???not-null="false"
    ???length="50"
    ??/>
    ??<property
    ???name="Email"
    ???column="email"
    ???type="string"
    ???not-null="false"
    ???length="50"
    ??/>
    ?

    ??<set name="ArticlesByLastUpdateBy" inverse="true" lazy="true">
    ???<key column="last_update_by"/>
    ???<one-to-many class="Article"/>
    ??</set>

    ??<set name="ArticlesByCreateBy" inverse="true" lazy="true">
    ???<key column="create_by"/>這里的create_by是后來修改的,Hibernate Sychonizer生成的有錯,后面有幾處同樣的錯誤】
    ???<one-to-many class="Article"/>
    ??</set>

    ??<set name="Boards" inverse="true" lazy="true">
    ???<key column="create_by"/>【這里的create_by是后來修改的】

    ???<one-to-many class="Board"/>
    ??</set>


    ?</class>?
    </hibernate-mapping>

    //User.java
    package com.lzy.forum.domain;


    public class User{
    ?private static final long serialVersionUID = 1L;

    //? primary key
    ?private java.lang.Integer id;

    ?// fields
    ?private java.lang.String name;
    ?private java.lang.String pwd;
    ?private java.lang.String email;

    ?// collections
    ?private java.util.Set<Article> articlesByLastUpdateBy;
    ?private java.util.Set<Article> articlesByCreateBy;
    ?private java.util.Set<Board> boards;
    ?
    ?
    ?public java.util.Set<Article> getArticlesByCreateBy() {
    ??return articlesByCreateBy;
    ?}
    ?public void setArticlesByCreateBy(java.util.Set<Article> articlesByCreateBy) {
    ??this.articlesByCreateBy = articlesByCreateBy;
    ?}
    ?public java.util.Set<Article> getArticlesByLastUpdateBy() {
    ??return articlesByLastUpdateBy;
    ?}
    ?public void setArticlesByLastUpdateBy(
    ???java.util.Set<Article> articlesByLastUpdateBy) {
    ??this.articlesByLastUpdateBy = articlesByLastUpdateBy;
    ?}
    ?public java.util.Set<Board> getBoards() {
    ??return boards;
    ?}
    ?public void setBoards(java.util.Set<Board> boards) {
    ??this.boards = boards;
    ?}
    ?public java.lang.String getEmail() {
    ??return email;
    ?}
    ?public void setEmail(java.lang.String email) {
    ??this.email = email;
    ?}
    ?public java.lang.Integer getId() {
    ??return id;
    ?}
    ?public void setId(java.lang.Integer id) {
    ??this.id = id;
    ?}
    ?public java.lang.String getName() {
    ??return name;
    ?}
    ?public void setName(java.lang.String name) {
    ??this.name = name;
    ?}
    ?public java.lang.String getPwd() {
    ??return pwd;
    ?}
    ?public void setPwd(java.lang.String pwd) {
    ??this.pwd = pwd;
    ?}


    }

    //Board.hbm.xml

    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC
    ?"-//Hibernate/Hibernate Mapping DTD//EN"
    ?"
    http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd " >

    <hibernate-mapping package="com.lzy.forum.domain">
    ?<class
    ??name="Board"
    ??table="board"
    ?>
    ???<meta attribute="sync-DAO">false</meta>
    ??<id
    ???name="Id"
    ???type="integer"
    ???column="id"
    ??>
    ???<generator class="native"/>
    ??</id>

    ??<property
    ???name="Name"
    ???column="name"
    ???type="string"
    ???not-null="true"
    ???length="50"
    ??/>
    ??<property
    ???name="Remark"
    ???column="remark"
    ???type="string"
    ???not-null="false"
    ???length="255"
    ??/>
    ??<property
    ???name="CreateTime"
    ???column="create_time"
    ???type="timestamp"
    ???not-null="false"
    ???length="19"
    ??/>
    ??<many-to-one
    ???name="CreateBy"
    ???column="create_by"
    ???class="User"
    ???not-null="true"
    ??>
    ??</many-to-one>
    ??<many-to-one
    ???name="Parent"
    ???column="parent_id"
    ???class="Board"???
    ???not-null="false"
    ???lazy="false">
    ??</many-to-one>
    ?

    ??<set name="Articles" inverse="true" lazy="true" order-by="id">
    ???<key column="board_id"/>【這里的board_id是后來修改的】
    ???<one-to-many class="Article"/>
    ??</set>

    ??<set name="ChildBoards" inverse="true"? lazy="true" order-by="id">
    ???<key column="parent_id"/>這里的parent_id是后來修改的】
    ???<one-to-many class="Board"/>
    ??</set>


    ?</class>?
    </hibernate-mapping>

    //Board.java
    package com.lzy.forum.domain;

    ?


    public class Board? {
    ?private static final long serialVersionUID = 1L;

    //? primary key
    ?private java.lang.Integer id;

    ?// fields
    ?private java.lang.String name;
    ?private java.lang.String remark;
    ?private java.util.Date createTime;

    ?// many to one
    ?private com.lzy.forum.domain.User createBy;
    ?private com.lzy.forum.domain.Board parent;

    ?// collections
    ?private java.util.Set<com.lzy.forum.domain.Article> articles;
    ?private java.util.Set<com.lzy.forum.domain.Board> childBoards;
    ?
    ?
    ?public java.util.Set<com.lzy.forum.domain.Article> getArticles() {
    ??return articles;
    ?}
    ?public void setArticles(java.util.Set<com.lzy.forum.domain.Article> articles) {
    ??this.articles = articles;
    ?}
    ?public java.util.Set<com.lzy.forum.domain.Board> getChildBoards() {
    ??return childBoards;
    ?}
    ?public void setChildBoards(java.util.Set<com.lzy.forum.domain.Board> childBoards) {
    ??this.childBoards = childBoards;
    ?}
    ?public com.lzy.forum.domain.User getCreateBy() {
    ??return createBy;
    ?}
    ?public void setCreateBy(com.lzy.forum.domain.User createBy) {
    ??this.createBy = createBy;
    ?}
    ?public java.util.Date getCreateTime() {
    ??return createTime;
    ?}
    ?public void setCreateTime(java.util.Date createTime) {
    ??this.createTime = createTime;
    ?}
    ?public java.lang.Integer getId() {
    ??return id;
    ?}
    ?public void setId(java.lang.Integer id) {
    ??this.id = id;
    ?}
    ?public java.lang.String getName() {
    ??return name;
    ?}
    ?public void setName(java.lang.String name) {
    ??this.name = name;
    ?}
    ?public com.lzy.forum.domain.Board getParent() {
    ??return parent;
    ?}
    ?public void setParent(com.lzy.forum.domain.Board parent) {
    ??this.parent = parent;
    ?}
    ?public java.lang.String getRemark() {
    ??return remark;
    ?}
    ?public void setRemark(java.lang.String remark) {
    ??this.remark = remark;
    ?}


    }

    //Article.hbm.xml

    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC
    ?"-//Hibernate/Hibernate Mapping DTD//EN"
    ?"
    http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd " >

    <hibernate-mapping package="com.lzy.forum.domain">
    ?<class
    ??name="Article"
    ??table="article"
    ?>
    ??<meta attribute="sync-DAO">false</meta>
    ??<id
    ???name="Id"
    ???type="integer"
    ???column="id"
    ??>
    ???<generator class="native"/>
    ??</id>

    ??<property
    ???name="ArticleType"
    ???column="article_type"
    ???type="integer"
    ???not-null="true"
    ???length="11"
    ??/>
    ??<property
    ???name="Title"
    ???column="title"
    ???type="string"
    ???not-null="false"
    ???length="255"
    ??/>
    ??<property
    ???name="Body"
    ???column="body"
    ???type="string"
    ???not-null="false"
    ??/>
    ??<property
    ???name="Hits"
    ???column="hits"
    ???type="integer"
    ???not-null="false"
    ???length="10"
    ??/>
    ??<property
    ???name="Bytes"
    ???column="bytes"
    ???type="integer"
    ???not-null="false"
    ???length="10"
    ??/>
    ??<property
    ???name="CreateTime"
    ???column="create_time"
    ???type="timestamp"
    ???not-null="false"
    ???length="19"
    ??/>
    ??<property
    ???name="LastUpdateTime"
    ???column="last_update_time"
    ???type="timestamp"
    ???not-null="false"
    ???length="19"
    ??/>
    ??<many-to-one
    ???name="LastUpdateBy"
    ???column="last_update_by"
    ???class="User"
    ???not-null="true"
    ??>
    ??</many-to-one>
    ??<many-to-one
    ???name="CreateBy"
    ???column="create_by"
    ???class="User"
    ???not-null="true"
    ??>
    ??</many-to-one>
    ??<many-to-one
    ???name="Parent"
    ???column="parent_id"
    ???class="Article"
    ???not-null="false"
    ??>
    ??</many-to-one>
    ??<many-to-one
    ???name="Board"
    ???column="board_id"
    ???class="Board"
    ???not-null="true"
    ??>
    ??</many-to-one>
    ?

    ??<set name="Articles" inverse="true" lazy="false" order-by="id">
    ???<key column="parent_id"/>【這里的parent_id是后來修改的】
    ???<one-to-many class="Article"/>
    ??</set>


    ?</class>?
    </hibernate-mapping>



    //Article.java
    package com.lzy.forum.domain;

    import java.util.Date;

    ?


    public class Article? {
    ?private static final long serialVersionUID = 1L;
    ?// primary key
    ?private java.lang.Integer id;

    ?// fields
    ?private java.lang.Integer articleType;
    ?private java.lang.String title;
    ?private java.lang.String body;
    ?private java.lang.Integer hits;
    ?private java.lang.Integer bytes;
    ?private java.util.Date lastUpdateTime;
    ?private java.util.Date createTime;
    ?

    ?// many to one
    ?private com.lzy.forum.domain.User lastUpdateBy;
    ?private com.lzy.forum.domain.User createBy;
    ?private com.lzy.forum.domain.Article parent;
    ?private com.lzy.forum.domain.Board board;

    ?// collections
    ?private java.util.Set<com.lzy.forum.domain.Article> articles;

    ?public java.util.Set<com.lzy.forum.domain.Article> getArticles() {
    ??return articles;
    ?}

    ?public void setArticles(java.util.Set<com.lzy.forum.domain.Article> articles) {
    ??this.articles = articles;
    ?}

    ?public java.lang.Integer getArticleType() {
    ??return articleType;
    ?}

    ?public void setArticleType(java.lang.Integer articleType) {
    ??this.articleType = articleType;
    ?}

    ?public com.lzy.forum.domain.Board getBoard() {
    ??return board;
    ?}

    ?public void setBoard(com.lzy.forum.domain.Board board) {
    ??this.board = board;
    ?}

    ?public java.lang.String getBody() {
    ??return body;
    ?}

    ?public void setBody(java.lang.String body) {
    ??this.body = body;
    ?}

    ?public java.lang.Integer getBytes() {
    ??return bytes;
    ?}

    ?public void setBytes(java.lang.Integer bytes) {
    ??this.bytes = bytes;
    ?}

    ?public com.lzy.forum.domain.User getCreateBy() {
    ??return createBy;
    ?}

    ?public void setCreateBy(com.lzy.forum.domain.User createBy) {
    ??this.createBy = createBy;
    ?}

    ?public java.lang.Integer getHits() {
    ??return hits;
    ?}

    ?public void setHits(java.lang.Integer hits) {
    ??this.hits = hits;
    ?}

    ?public java.lang.Integer getId() {
    ??return id;
    ?}

    ?public void setId(java.lang.Integer id) {
    ??this.id = id;
    ?}

    ?public com.lzy.forum.domain.User getLastUpdateBy() {
    ??return lastUpdateBy;
    ?}

    ?public void setLastUpdateBy(com.lzy.forum.domain.User lastUpdateBy) {
    ??this.lastUpdateBy = lastUpdateBy;
    ?}

    ?public java.util.Date getLastUpdateTime() {
    ??return lastUpdateTime;
    ?}

    ?public void setLastUpdateTime(java.util.Date lastUpdateTime) {
    ??this.lastUpdateTime = lastUpdateTime;
    ?}

    ?public com.lzy.forum.domain.Article getParent() {
    ??return parent;
    ?}

    ?public void setParent(com.lzy.forum.domain.Article parent) {
    ??this.parent = parent;
    ?}

    ?public java.lang.String getTitle() {
    ??return title;
    ?}

    ?public void setTitle(java.lang.String title) {
    ??this.title = title;
    ?}
    ?public java.util.Date getCreateTime(){
    ??return createTime;
    ?}

    ?public void setCreateTime(java.util.Date createTime) {
    ??// TODO Auto-generated method stub
    ??this.createTime = createTime;
    ?}
    ?

    }

    接下來將會在web中加入Spring支持和為實體類提供DAO支持。(未完待續)

    posted @ 2006-07-18 09:54 all gone 閱讀(1785) | 評論 (2)編輯 收藏

    Eclipse + CDT + MinGW 下編寫QT程序


    環境:
    (1)安裝Eclipse + CDT + MinGW
    (2)安裝QT for Windows
    (3)安裝QT plugin for Eclipse :org.eclipse.qt-1.0.2.zip,在Preference里設好相關路徑。

    新建一個 QT project,將hello。cpp復制到工程中:
    #include <QApplication>
    #include <QPushButton>

    int main(int argc, char *argv[]){
    ?
    ?QApplication app(argc, argv);
    ?
    ?QPushButton hello("Hello world!");
    ?
    ?hello.resize(100, 30);
    ?hello.show();
    ?
    ?return app.exec();
    }

    build后生成Makefile,新建兩個Make Target:all,clean
    Make all 后發現找不到libQtCored4.a等文件,在QT的lib目錄下找到相應的libQtCore4.a,復制后重命名為libQtCored4.a,
    其他庫文件類似,最后編譯通過,運行后出現帶hello按鈕的窗口。

    ?

    posted @ 2006-06-16 19:45 all gone 閱讀(1181) | 評論 (0)編輯 收藏

    Eclipse + CDT + MinGW 下編寫OpenGL程序


    Eclipse + CDT + MinGW環境的搭建比較簡單,由于機器內存不夠大,我在preference里將C++的indexer都置為NO INDEXER。
    安裝MinGW后可以看到,在Include和Lib目錄下有了與OpenGL相關的頭文件和靜態庫。為了使用GLUT,我將glut.h放到了相應的
    GL目錄下,看到Lib目錄下有libglut.a庫文件,我沒有將glut。lib放進去(后來發現libglut。a好像在windows不可用)。

    新建一個Standtart Make C++ project,將原來可運行的OpenGL程序復制過來,寫好Makefile,結果編譯的時候還是出現錯誤。
    還好找到了這個非常有用的網頁:http://www.mingw.org/MinGWiki/index.php/Glut
    按照上面列出的錯誤,我在每個#include<GL/glut.h>前都加上#define _STDCALL_SUPPORTED,然后又將glut32。lib、
    opengl32.lib、glu32.lib都放到當前的工程目錄下,用”glut32。lib opengl32.lib glu32.lib“ 代替原來的 ”-lglut -lopengl32 -lglu32",
    最后終于編譯通過。

    ?

    posted @ 2006-06-16 19:33 all gone 閱讀(1183) | 評論 (0)編輯 收藏

    EJB 3.0 學習筆記——Entity Bean

         摘要: 在EJB 3.0 學習筆記——準備工作中只是簡單的搭好了EJB3.0開發的基本環境,之 后就可以開發最簡單的Session Bean了,我感興趣的還是Entity Bean,所以接下來 我想先試驗一下Entity Bean。?一、在JBoss中配置好Data Source我使用的是MySQL數據庫,所以首先將MySQL的JDBC驅動復制到jboss-4.0.3SP1\server\al...  閱讀全文

    posted @ 2006-05-20 22:38 all gone 閱讀(3379) | 評論 (4)編輯 收藏

    JavaScript和Applet互相調用

    Java Script 調用 java 可以在網頁里使用

    <script language=javascript>

    ?????? document.applet_name.method_name();

    </script>

    可以對 applet 進行控制,也可以從 applet 返回值。

    ?

    ?

    Java 調用 Java Script

    需要導入 netscape.javascript.jsobject 這個類 (jre/lib/plugin.jar)

    比如:

    JSObject window=JSObject.getWindow(this);

    JSObject window=(JSObject)window.getMember("document");

    來獲取對當前窗口的控制權。

    ?

    當點擊鏈接 MakeCall 時,會觸發 Java Script 函數

    ?

    function makeCall(s){

    ? window.document.ctiApplet.testJavascript(s);

    ? alert("call maked!");

    ?}

    ?

    在這個 Java Script 函數中, ctiApplet 是一個 Applet ,這樣完成了 java script 調用

    Applet

    以下是 ctiApplet 中的 testJavascript 函數和運行結果,其中又調用了 Java Script
    public void testJavascript(String msg){

    ??????

    ?

    ?????? try {

    ????????????? // create JSObject

    ?

    ?????? ??? ?????? JSObject.getWindow (this).eval ("javascript:alert('Java Script in Applet!')") ;

    ?????? }

    ?????? catch (Exception ex) {

    ????????????? // Error on create JSObject

    ?????? ??? ?????? showStatus( "Error call javascript err=" + ex );

    ?????? }

    ?

    ?????? System.out.println(msg);

    }

    ?

    ?

    ?

    posted @ 2006-05-04 09:41 all gone 閱讀(449) | 評論 (0)編輯 收藏

    EJB 3.0 學習筆記——準備工作


    在開發EJB3.0 之前,首先應該去下載它的一個實現和一個相應的支持EJB3的服務器,我下載的是jboss-EJB-3.0_RC5-PFD和JBoss 4.0.3SP1 ,jboss-EJB-3.0_RC5-PFD里面有安裝說明和一些不錯的tutorial。

    根據安裝說明,JBoss 4.0.3SP1中的EJB3實現不是最新的,應用下載的jboss-EJB-3.0_RC5-PFD中的一些包去替換。

    將jboss-EJB-3.0_RC5-PFD中lib目錄下的
    ?(1)ejb3.deployer/
    ?(2)ejb3-clustered-sfsbcache-service.xml
    ?(3)ejb3-interceptors-aop.xml
    ?(4)jboss-aop-jdk50.deployer/
    拷貝到jboss-4.0.3SP1/server/all/deploy目錄下

    將jboss-EJB-3.0_RC5-PFD中lib目錄下的
    ?(5)jboss-remoting.jar
    ?(6)jboss-serialization.jar
    ?(7)jboss-j2ee.jar
    拷貝到jboss-4.0.3SP1/server/all/lib目錄下


    刪除jboss-4.0.3SP1/server/all/lib 下的
    ?(1)ejb3-persistence.jar
    ?(2)hibernate3.jar
    ?(3)hibernate-annotations.jar
    ?(4)hibernate-entitymanager.jar
    和jboss-4.0.3SP1/server/all/deploy下的
    ?(5)jboss-aop.deployer/
    到此EJB3 的運行環境準備好了,你可以用jboss-4.0.3SP1\bin\run -c all 測試JBoss是否能成功啟動。

    我用的IDE是Eclipse 3.2,JDK 1.5 ,為了方便在Eclipse中新建一個User Library:EJB3_JBoss,
    將jboss-EJB-3.0_RC5-PFD\lib下的
    ?jboss-j2ee.jar
    和jboss-EJB-3.0_RC5-PFD\lib\ejb3.deployer下的
    ?ejb3-persistence.jar
    ?jboss-ejb3x.jar
    ?jboss-ejb3.jar
    ?jboss-annotations-ejb3.jar
    ?hibernate3.jar
    ?hibernate-annotations.jar
    ?hibernate-entitymanager.jar
    添加到EJB_JBoss中,現在環境基本上搭好了。

    posted @ 2006-03-26 23:05 all gone 閱讀(956) | 評論 (1)編輯 收藏

    FreeBSD 5.3 中的聲卡問題



    在FreeBSD 5.x中,kernel配置文件的設備名改為sound,不是FreeBSD 4.x中的pcm了,以后還有可能改為snd。


    #cd /usr/src/sys/i386/conf/
    #make LINT
    可生成LINT文件,將kernel配置里的項全部列出了。


    在kernel配置文件里加上
    device sound
    device snd_foo 或
    device "snd_foo" <----注意這里foo表示不同的聲卡種類,可參考LINT文件。


    如果不知道你的聲卡應該用哪一個,可以先用
    #kldload snd_driver 將所有常用的聲卡驅動裝載,然后用


    #cat /dev/sndstat 察看是否有相應的聲卡信息,如:
    FreeBSD Audio Driver (newpcm)
    Installed devices:
    pcm0: at io 0xd800, 0xdc80 irq 5 bufsz 16384
    kld snd_ich (1p/2r/0v channels duplex default)


    這里snd_inc就是對應的應該裝載的設備。


    注意如果對應的聲卡種類中有數字,就應該加上引號。


    這樣重新編譯內核就可以了。當然如果不編譯內核,用load module的方式也可以。



    那么我的問題是什么呢? 我用
    #dmesg|grep pcm 能察看到聲卡信息。
    用 #cat /dev/sndstat 也能看到正確的聲卡信息。
    并且能夠播放CD,但是使用xmms等軟件播放mp3文件的時候,播放條根本不走。而后從dmesg可看到如下信息:


    pcm0:play:0: play interrupt timeout, channel dead


    經過Google查詢,懷疑問題出在系統ICQ沖突上。最后,在啟動FreeBSD 5.3時,選擇了ACPI Disable,就能夠正確地用xmms播放了。


    最后補充以下,我的機器安裝了兩塊網卡,一塊SCSI卡。使用的是版載聲卡。怎么解決在ACPI情況下使用還不清楚。但問題基本確定的確是ICQ資源的問題。

    posted @ 2006-01-05 21:56 all gone 閱讀(230) | 評論 (0)編輯 收藏

    FreeBSD安裝問題及漢化

    五一這幾天沒事閑的裝了FreeBSD,時間可沒少花,問題卻還是不少,也許對系統還不是太熟悉吧.

    1.USB鼠標的問題

    第一次裝的時候,測試鼠標的時候沒動靜,不知當時是不是鼠標沒插好
    只好用PS/2口了,后來編譯了一遍內核,USB才能用.

    然而最后一次裝的時候,USB口可以用,但是startx進入KDE的時候總是失敗,找不到什么Pointer,將鼠標插入
    PS/2口后重啟,上述現象又沒了,感覺很是奇怪,進入kde后將鼠標插入USB口也正常.

    2..xinitrc文件的問題

    第一次裝的時候是按照書上裝的,當時把xinitrc文件復制過來

    cp /usr/X11R6/lib/X11/xinitrc/xinitrc /root/.xinitrc

    3.中文字體和輸入法



    首先安裝cvsup,更新ports,然后安裝kde-zh******,之后就可以看到kde的一些界面已經中文化了,但是還是有亂碼,弄個中文字體過來就可以了

    將windows中的simsun.ttc改名為simsun.ttf后復制到/usr/X11R6/lib/X11/fonts/TTF中,然后運行命令

    fc-cache -f -v就可以了

    中文輸入法很簡單.fcitx,不過以前裝的時候沒有更新ports時好象不行.

    posted @ 2006-01-05 21:55 all gone 閱讀(225) | 評論 (0)編輯 收藏

    FreeBSD上預留的UID和GID

    目前預留的 50 到 999 之間的 UID。

    bind:*:53:53:Bind Sandbox:/:/sbin/nologin
    majordom:*:54:54:Majordomo Pseudo User:/usr/local/majordomo:/nonexistent
    rdfdb:*:55:55:rdfDB Daemon:/var/db/rdfdb:/bin/sh
    spamd:*:58:58:SpamAssassin user:/var/spool/spamd:/sbin/nologin
    cyrus:*:60:60:the cyrus mail server:/nonexistent:/nonexistent
    gnats:*:61:1:GNATS database owner:/usr/local/share/gnats/gnats-db:/bin/sh
    proxy:*:62:62:Packet Filter pseudo-user:/nonexistent:/nonexistent
    uucp:*:66:66:UUCP pseudo-user:/var/spool/uucppublic:/usr/libexec/uucp/uucico
    xten:*:67:67:X-10 daemon:/usr/local/xten:/nonexistent
    pop:*:68:6:Post Office Owner (popper):/nonexistent:/sbin/nologin
    wnn:*:69:7:Wnn:/nonexistent:/nonexistent
    pgsql:*:70:70:PostgreSQL pseudo-user:/usr/local/pgsql:/bin/sh
    oracle:*:71:71::0:0:Oracle:/usr/local/oracle7:/sbin/nologin
    ircd:*:72:72:IRC daemon:/nonexistent:/nonexistent
    ircservices:*:73:73:IRC services:/nonexistent:/nonexistent
    simscan:*:74:74:Simscan User:/nonexistent:/sbin/nologin
    ifmail:*:75:66:Ifmail user:/nonexistent:/nonexistent
    www:*:80:80:World Wide Web Owner:/nonexistent:/sbin/nologin
    alias:*:81:81:QMail user:/var/qmail/alias:/nonexistent
    qmaild:*:82:81:QMail user:/var/qmail:/nonexistent
    qmaill:*:83:81:QMail user:/var/qmail:/nonexistent
    qmailp:*:84:81:QMail user:/var/qmail:/nonexistent
    qmailq:*:85:82:QMail user:/var/qmail:/nonexistent
    qmailr:*:86:82:QMail user:/var/qmail:/nonexistent
    qmails:*:87:82:QMail user:/var/qmail:/nonexistent
    mysql:*:88:88:MySQL Daemon:/var/db/mysql:/sbin/nologin
    vpopmail:*:89:89:VPop Mail User:/usr/local/vpopmail:/nonexistent
    firebird:*:90:90:Firebird Database Administrator:/usr/local/firebird:/bin/sh
    mailman:*:91:91:Mailman User:/usr/local/mailman:/sbin/nologin
    gdm:*:92:92:GDM Sandbox:/:/sbin/nologin
    jabber:*:93:93:Jabber Daemon:/nonexistent:/nonexistent
    p4admin:*:94:94:Perforce admin:/usr/local/perforce:/sbin/nologin
    interch:*:95:95:Interchange user:/usr/local/interchange:/sbin/nologin
    squeuer:*:96:96:SQueuer Owner:/nonexistent:/bin/sh
    mud:*:97:97:MUD Owner:/nonexistent:/bin/sh
    msql:*:98:98:mSQL-2 pseudo-user:/var/db/msqldb:/bin/sh
    rscsi:*:99:99:Remote SCSI:/usr/local/rscsi:/usr/local/sbin/rscsi
    squid:*:100:100:squid caching-proxy pseudo user:/usr/local/squid:/sbin/nologin
    quagga:*:101:101:Quagga route daemon pseudo user:/usr/local/etc/quagga:/sbin/nologin
    ganglia:*:102:102:Ganglia User:/nonexistent:/sbin/nologin
    sgeadmin:*:103:103:Sun Grid Engine Admin:/nonexistent:/sbin/nologin
    slimserv:*:104:104:Slim Devices SlimServer pseudo-user:/nonexistent:/sbin/nologin
    dnetc:*:105:105:distributed.net client and proxy pseudo-user:/nonexistent:/sbin/nologin
    clamav:*:106:106:Clamav Antivirus:/nonexistent:/sbin/nologin
    cacti:*:107:107:Cacti Sandbox:/nonexistent:/sbin/nologin
    webkit:*:108:108:WebKit Default User:/usr/local/www/webkit:/bin/sh
    quickml:*:109:109:quickml Server:/nonexistent:/sbin/nologin
    vscan:*:110:110:Scanning Virus Account:/var/amavis:/bin/sh
    fido:*:111:111:Fido System:/usr/local/fido:/bin/sh
    dcc:*:112:112:Distributed Checksum Clearinghouse:/nonexistent:/sbin/nologin
    amavis:*:113:113:Amavis-stats Account:/nonexistent:/sbin/nologin
    dhis:*:114:114:DHIS Daemon:/nonexistent:/sbin/nologin
    _symon:*:115:115:Symon Account:/var/empty:/sbin/nologin
    postfix:*:125:125:Postfix Mail System:/var/spool/postfix:/sbin/nologin
    rbldns:*:153:153:rbldnsd pseudo-user:/nonexistent:/sbin/nologin
    sfs:*:171:171:Self-Certifying File System:/nonexistent:/sbin/nologin
    agk:*:172:172:AquaGateKeeper:/nonexistent:/nonexistent
    polipo:*:173:173:polipo web cache:/nonexistent:/sbin/nologin
    bogomilter:*:174:174:milter-bogom:/nonexistent:/sbin/nologin
    moinmoin:*:192:192:MoinMoin User:/nonexistent:/sbin/nologin
    sympa:*:200:200:Sympa Owner:/nonexistent:/sbin/nologin
    dspam:*:202:202:Dspam:/nonexistent:/sbin/nologin
    _tor:*:256:256:Tor anonymising router:/var/db/tor:/bin/sh
    ldap:*:389:389:OpenLDAP Server:/nonexistent:/sbin/nologin
    drweb:*:426:426:Dr.Web Mail Scanner:/nonexistent:/sbin/nologin
    courier:*:465:465:Courier Mail Server:/nonexistent:/sbin/nologin
    _bbstored:*:505:505::0:0:BoxBackup Store Daemon:/nonexistent:/bin/sh
    qtss:*:554:554:Darwin Streaming Server:/nonexistent:/sbin/nologin
    ircdru:*:555:555:Russian hybrid IRC server:/nonexistent:/bin/sh
    messagebus:*:556:556:D-BUS Daemon User:/nonexistent:/sbin/nologin
    bnetd:*:700:700:Bnetd user:/nonexistent:/sbin/nologin
    bopm:*:717:717:Blitzed Open Proxy Monitor:/nonexistent:/bin/sh
    bacula:*:910:910:Bacula Daemon:/var/db/bacula:/sbin/nologin


    下面是目前預留的 GID。

    bind:*:53:
    rdfdb:*:55:
    spamd:*:58:
    cyrus:*:60:
    proxy:*:62:
    authpf:*:63:
    uucp:*:66:
    xten:*:67:
    dialer:*:68:
    network:*:69:
    pgsql:*:70:
    simscan:*:74:
    www:*:80:
    qnofiles:*:81:
    qmail:*:82:
    mysql:*:88:
    vpopmail:*:89:
    firebird:*:90:
    mailman:*:91:
    gdm:*:92:
    jabber:*:93:
    p4admin:*:94:
    interch:*:95:
    squeuer:*:96:
    mud:*:97:
    msql:*:98:
    rscsi:*:99:
    squid:*:100:
    quagga:*:101:
    ganglia:*:102:
    sgeadmin:*:103:
    slimserv:*:104:
    dnetc:*:105:
    clamav:*:106:
    cacti:*:107:
    webkit:*:108:
    quickml:*:109:
    vscan:*:110:
    fido:*:111:
    dcc:*:112:
    amavis:*:113:
    dhis:*:114:
    _symon:*:115:
    postfix:*:125:
    maildrop:*:126:
    rbldns:*:153:
    sfs:*:171:
    agk:*:172:
    polipo:*:173:
    moinmoin:*:192:
    sympa:*:200:
    dspam:*:202:
    _tor:*:256:
    ldap:*:389:
    drweb:*:426:
    courier:*:465:
    _bbstored:*:505:
    qtss:*:554:
    ircdru:*:555:
    messagebus:*:556:
    realtime:*:557:
    bnetd:*:700:
    bopm:*:717:
    bacula:*:910:

    posted @ 2005-12-23 16:53 all gone 閱讀(550) | 評論 (0)編輯 收藏

    JSP 處理MySQL數據庫時的中文問題

    以前遇到JSP 處理MySQL數據庫時的中文問題時,采取的是很笨的一種方法,直接用字符串編碼轉換函數進行轉換,這次從網上搜了一下,找到了一個使用Filter的可行方法。在Tomcat 5.5+ MySQL4.0.16下通過。

    filter類源碼是從網上找的,如下
    /**
     *
     */
    package com.lzy;

    import java.io.IOException;
    import javax.servlet.Filter;
    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;

    /**
     * @author lzy
     *
     */
    public class SetCharacterEncodingFilter implements Filter {
     
     protected String encoding = null;
        protected FilterConfig filterConfig = null;
        protected boolean ignore = true;


     /* (non-Javadoc)
      * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
      */
     public void init(FilterConfig filterConfig) throws ServletException {
      // TODO Auto-generated method stub
      this.filterConfig = filterConfig;
         this.encoding = filterConfig.getInitParameter("encoding");
         String value = filterConfig.getInitParameter("ignore");
         if (value == null)
          this.ignore = true;
         else if (value.equalsIgnoreCase("true"))
          this.ignore = true;
         else if (value.equalsIgnoreCase("yes"))
          this.ignore = true;
         else
          this.ignore = false;


     }

     /* (non-Javadoc)
      * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
      */
     public void doFilter(ServletRequest request, ServletResponse response,
       FilterChain chain) throws IOException, ServletException {
      
      // TODO Auto-generated method stub
      if (ignore || (request.getCharacterEncoding() == null)) {
       String encoding = selectEncoding(request);
       if (encoding != null)
        request.setCharacterEncoding(encoding);
      }
      chain.doFilter(request, response);
     }

     /* (non-Javadoc)
      * @see javax.servlet.Filter#destroy()
      */
     public void destroy() {
      // TODO Auto-generated method stub
      
      this.encoding = null;
         this.filterConfig = null;


     }
     
      protected String selectEncoding(ServletRequest request) {

             return (this.encoding);

         }


    }

    在web.xml 文件中作如下設置:(我使用的是Struts框架)
    <filter>
    <filter-name>Encoding</filter-name>
    <filter-class>com.lzy.SetCharacterEncodingFilter</filter-class>
    <init-param>
    <param-name>encoding</param-name>
    <param-value>GBK</param-value>
    </init-param>
    </filter>

    <filter-mapping>
    <filter-name>Encoding</filter-name>
    <servlet-name>action</servlet-name>
    </filter-mapping>
    <filter-mapping>
    <filter-name>Encoding</filter-name>
    <url-pattern>*.jsp</url-pattern>
    </filter-mapping>


    最后,連接數據庫時,使用下面的url:
    jdbc:mysql://localhost:3306/數據庫名?useUnicode=true&characterEncoding=GBK

    posted @ 2005-12-18 22:57 all gone 閱讀(480) | 評論 (0)編輯 收藏

    Spring之Hello World

    1.下載Spring相關的開發包
    下載地址:http://sourceforge.net/project/showfiles.php?group_id=73357
    有spring-framework-1.2.6-with-dependencies.zip,一個是spring-framework-1.2.6.zip,最好下載with-dependencies的,里面有另外一些附加包,下載后解壓縮,dist目錄下是spring自身的jar,lib目錄下是附加的jar。
    2.新建Java Project,將spring.jar(dist目錄下)和commons-logging.jar(lib目錄下)添加到project的build path中。
    3.新建POJO Bean類:HelloBean
    //HelloBean.java
    /**
     *
     */
    package com.lzy;

    /**
     * @author lzy
     *
     */
    public class HelloBean{
     
     private String hello;
     
     public void sayHello(){
      System.out.println(this.getHello());
     }

     /**
      * @return Returns the hello.
      */
     public String getHello() {
      return hello;
     }

     /**
      * @param hello The hello to set.
      */
     public void setHello(String hello) {
      this.hello = hello;
     }
     

    }


    4.新建文件bean.xml,將在這個XML文件中為一個HelloBean的實例的hello屬性賦值。
    //bean.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "<beans>
    <description>Spring Quick Start</description>
    <bean id="helloBean" class="com.lzy.HelloBean">
      <property name="hello">
       <value>hello world</value>
      </property>
    </bean>
    </beans>

    5.新建測試類:TestSpring
    //TestSpring.java
    /**
     *
     */
    package com.lzy;

    import java.util.Locale;

    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.FileSystemXmlApplicationContext;

    /**
     * @author lzy
     *
     */
    public class TestSpring {

     /**
      * @param args
      */
     public static void main(String[] args) {
      // TODO Auto-generated method stub
      
      ApplicationContext ctx=new FileSystemXmlApplicationContext("bean.xml");
        HelloBean hello=(HelloBean)ctx.getBean("helloBean");
      hello.sayHello();
     }

    }


    6.運行測試類:
        如果沒有出錯,輸出中將會看到“hello world”。

    posted @ 2005-12-14 22:07 all gone 閱讀(1047) | 評論 (0)編輯 收藏

    Eclipse下Hibernate入門


    1.開發環境
         Eclipse 3.2+MySQL 4.0.16+Hibernate3.0
        首先應該安裝好Eclipse和MySQL,此外準備好MySQL的JDBC Driver和Hibernate3.0,相關下載地址如下:
         Eclipse SDK:
            http://www.eclipse.org/downloads/index.php 
           MySQL及MySQL的JDBC Driver:
               http://www.mysql.org
           Hibernate:
              http://www.hibernate.org
           此外我還安裝了Eclipse的一個Hibernate插件:
         Hibernate synchronizer
               http://hibernatesynch.sourceforge.net


           Plugin Search:
             http://eclipse-plugins.2y.net/eclipse/search.jsp 

           Hibernate synchronizer插件的安裝和配置有問題請直接Google。

         在工程中其實只用到了Hibernate synchronizer插件的一部分功能,Hibernate依賴的相關jar包最好還是手動添加,因為最開始用Hibernate synchronizer添加時總是發生錯誤。
         將下載的Mysql driver和Hibernate包解壓縮,我們需要的只是里面相關的jar,在Eclipse中新建Mysql_Driver和Hibernate兩個user library,將mysql-connector-java-3.0.15-ga-bin.jar加入Mysql_Driver中,將hibernate3.jar,
    ,log4j-1.2.11.jar,antlr-2.7.5H3.jar,asm.jar,asm-attrs.jar,cglib-2.1.2.jar,commons-collections-2.1.1.jar,commons-logging-1.0.4.jar,dom4j-1.6.1.jar,ehcache-1.1.jar,jta.jar加入到Hibernate中。

    2.開始
    在Mysql中新建test數據庫(Mysql其實有個空的test數據庫),然后新建下面的Table

    create table user (
     id int(10) not null auto_increment primary key,
     name varchar(20) not null,
     password varchar(20) not null,
     email varchar(50),
     address varchar(100)
    )type=innodb;


    新建Java Project,將Mysql_Driver,Hibernate兩個user library添加到該工程的java build path中。

    新建與數據表對應的POJO類:User和Contact

    /**
     *
     * 
     */
    package com.user;

    /**
     * @author lzy
     *
     */
    public class User{
        private Integer id;
        private String name;
        private String password;
        private Contact contact;
       

     /**
      * @return Returns the id.
      */
     public Integer getId() {
      return id;
     }
     /**
      * @param id The id to set.
      */
     public void setId(Integer id) {
      this.id = id;
     }
     /**
      * @return Returns the name.
      */
     public String getName() {
      return name;
     }
     /**
      * @param name The name to set.
      */
     public void setName(String name) {
      this.name = name;
     }
     /**
      * @return Returns the password.
      */
     public String getPassword() {
      return password;
     }
     /**
      * @param password The password to set.
      */
     public void setPassword(String password) {
      this.password = password;
     }
     /**
      * @return Returns the contact.
      */
     public Contact getContact() {
      return contact;
     }
     /**
      * @param contact The contact to set.
      */
     public void setContact(Contact contact) {
      this.contact = contact;
     }
       
       
    }
    /**
     *
     */
    package com.user;

    /**
     * @author lzy
     *
     */
    public class Contact {
     private String email;
        private String address;

     /**
      * @return Returns the address.
      */
     public String getAddress() {
      return address;
     }
     /**
      * @param address The address to set.
      */
     public void setAddress(String address) {
      this.address = address;
     }
     /**
      * @return Returns the email.
      */
     public String getEmail() {
      return email;
     }
     /**
      * @param email The email to set.
      */
     public void setEmail(String email) {
      this.email = email;
     }
    }

    之后可以用synchronizer插件生成Hibernate配置文件和映射文件(相關過程可以參考http://www.ideagrace.com/html/doc/2005/08/01/00315.html),不過映射文件必須稍作修改。

    hibernate.cfg.xml
    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE hibernate-configuration
        PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
        "

    <hibernate-configuration>
        <session-factory >

      <!-- local connection properties -->
      <property name="hibernate.connection.url">jdbc:mysql://localhost/test</property>
      <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
      <property name="hibernate.connection.username"></property>
      <property name="hibernate.connection.password"></property>
      <!-- property name="hibernate.connection.pool_size"></property -->

      <!-- dialect for MySQL -->
            <property name="dialect">org.hibernate.dialect.MySQLDialect</property>

            <property name="hibernate.show_sql">True</property>
            <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
         <mapping resource="User.hbm.xml"/>


        </session-factory>
    </hibernate-configuration>

    User.hbm.xml

    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC
     "-//Hibernate/Hibernate Mapping DTD//EN"
     "

    <hibernate-mapping package="com.user">
     <class
      name="User"
      table="user"
     >
      <id
       name="Id"
       type="integer"
       column="id"
      >
       <generator class="native"/>
      </id>

      <property
       name="Name"
       column="name"
       type="string"
       not-null="true"
       length="20"
      />
      <property
       name="Password"
       column="password"
       type="string"
       not-null="true"
       length="20"
      />
      <component name="Contact" class="Contact">
       <property
       name="Email"
       column="email"
       type="string"
       not-null="false"
       length="50"
      />
      <property
       name="Address"
       column="address"
       type="string"
       not-null="false"
       length="100"
      />
      </component>
      


     </class> 
    </hibernate-mapping>

     

    3.測試
    添加一個測試類:HibernateTest

    package com.user;

    import java.util.List;
    import java.util.ListIterator;

    import org.hibernate.*;
    import org.hibernate.cfg.*;

    public class HibernateTest {
        public static void main(String[] args) throws HibernateException {
            SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
           
            //
            //testInsert(sessionFactory);
           
            //
            testQuery(sessionFactory);
           
             
            sessionFactory.close();
           
        }
        public static void testInsert( SessionFactory sessionFactory )throws HibernateException {
         
          Session session = sessionFactory.openSession();
            Transaction tx= session.beginTransaction();
            User user = new User();
            Contact contact=new Contact();
            contact.setEmail("email");
            contact.setAddress("address");
           
            user.setName("caterpillar");
            user.setPassword("password");
            user.setContact(contact);
           
            session.save(user);
            tx.commit();
            session.close();
            System.out.println("OK!");
       }
       
        public static void testQuery( SessionFactory sessionFactory )throws HibernateException {
         
         Session session = sessionFactory.openSession();
            Transaction tx= session.beginTransaction();
            User user = new User();
            Contact contact=new Contact();
                     
            Query query=session.createQuery("from User as user");
            //query.setCharacter(1, 'M');
            List names =query.list();
            for(ListIterator it=names.listIterator();it.hasNext();){
               user= (User)it.next();
               System.out.println("Id: " + user.getId());
                System.out.println("name: " + user.getName());
                System.out.println("password: " + user.getPassword());
                if(user.getContact()!=null){
                 
                 if(user.getContact().getEmail()!=null){
                  System.out.println("Email: " + user.getContact().getEmail());
                 }
                 if(user.getContact().getAddress()!=null){
                  System.out.println("Address: " + user.getContact().getAddress());
                   
                 }
                }
               
               
               
            }
             
          
            tx.commit();
            session.close();
         
        }
    }

     

      

     

    posted @ 2005-12-10 12:50 all gone 閱讀(5032) | 評論 (3)編輯 收藏

    Eclipse下JSF入門

    1.開發環境
       與Eclipse下Struts的開發類似,安裝好Eclipse和Tomcat之后,還需要兩個插件:tomcat 插件和JSF插件(如果相關插件還沒有安裝),以下是相關下載地址:
        Eclipse SDK:
            http://www.eclipse.org/downloads/index.php 
        JSF:
         https://sourceforge.jp/projects/amateras/files/  
          FaceIDE+htmlEditor,htmlEditer也是必要的
        Tomcat :
             http://www.sysdeo.com/eclipse/tomcatplugin 
        Plugin Search:
             http://eclipse-plugins.2y.net/eclipse/search.jsp 
       插件的安裝和配置有問題請直接Google。
    2.開始
        入門嘛,我們就找一個最簡單的Login就可以了

        新建Tomcat project
        加入JSF支持

        新建一個ManagedBean:


    /**
     *
     */
    package com.jsf;




    /**
     * @author lzy
     *
     */
    public class UserBean {
    private String name;
        private String password;
    public String verify() {
         if(this.name.equals("name")&&this.password.equals("password"))
         
            return "failure";

       else
            return "success";
    }

     
    /**
    * @return Returns the name.
    */
    public String getName() {
    return name;
    }

    /**
    * @param name The name to set.
    */
    public void setName(String name) {
    this.name = name;
    }


    /**
    * @return Returns the password.
    */
    public String getPassword() {
    return password;
    }

    /**
    * @param password The password to set.
    */
    public void setPassword(String password) {
    this.password = password;
    }


    }

         新建兩個JSP頁面,login.jsp,welcom.jsp

    login.jsp
    <%@ page contentType="text/html; charset=GBK" %>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

    <html>
    <head>
    <%@ page contentType="text/html; charset=GBK" %>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

    <html>
    <head>
    <link href="main.css" rel="stylesheet"/>
    <title></title>

    </head>
    <body>
        <f:view>
        <f:loadBundle basename="com.jsf.MessageResources" var="msgs"></f:loadBundle>
       
            <h:form>
            <h:panelGrid columns="3" headerClass="header" rowClasses="evenRow,oddRow">
            <f:facet name="header" >
            <h:outputText value="#{msgs.header}"/>
            </f:facet>
           
            <h:outputText value="#{msgs.namePromt}"></h:outputText>
            <h:inputText id="name"  required="true" value="#{user.name}">
            <f:validateLength minimum="2" maximum="10"></f:validateLength>
            </h:inputText>
            <h:message for="name" errorClass="errors"/>
           
           
            <h:outputText value="#{msgs.passwordPromt}"></h:outputText>
           
            <h:inputSecret id="password" value="#{user.password}" required="true" redisplay="true">
            <f:validateLength minimum="2"></f:validateLength>
            </h:inputSecret>
            <h:message for="password"/>
           
           
                  <f:facet name="footer" >
            <h:outputText value="#{msgs.footer}"/>
            </f:facet>
            </h:panelGrid>          
                <h:commandButton value="#{msgs.submitPromt}" action="#{user.verify}"/>
                <h:commandButton value="#{msgs.resetPromt}" type="reset"/>
            </h:form>
        </f:view>
    </body>
    </html>



    welcome.jsp


    <%@ page contentType="text/html; charset=GBK" %>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=GBK"/>
    <title></title>
    </head>
    <body>
        <f:view>
            <h:outputText value="#{user.name}"/>  is a good boy!
            <h3>welcome JavaServer Faces</h3>
        </f:view>
    </body>

    </html>
         編輯WEB-INF/lib下的faces-config.xml

    struts-config.xml

    <?xml version="1.0"?>
    <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN" "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
    <faces-config>
    <navigation-rule>
            <from-view-id>/login.jsp</from-view-id>
            <navigation-case>
                <from-outcome>success</from-outcome>
                <to-view-id>/welcome.jsp</to-view-id>
            </navigation-case>
            <navigation-case>
                <from-outcome>failure</from-outcome>
                <to-view-id>/login.jsp</to-view-id>
            </navigation-case>
    </navigation-rule>


    <managed-bean>
    <managed-bean-name>user</managed-bean-name>
    <managed-bean-class>com.jsf.UserBean</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>
    </faces-config>


           最后是資源文件

    # --login.jsp--
    header=Welcom
    namePromt=Name:
    passwordPromt=Password:
    amountPromt=Amount:
    datePromt=Date:
    submitPromt=Submit
    resetPromt=Reset
    footer=Thank you!


    3.測試
    在test工程中選擇tomcat project->Update context definition
    然后運行Tomcat
    http://127.0.0.1:8080/jsfTest/login.jsf

    posted @ 2005-12-10 12:05 all gone 閱讀(17651) | 評論 (11)編輯 收藏

    Eclipse下Struts開發入門

     

    1.開發環境
       開發之前首先應該準備好開發環境,Eclipse 3.X是一個不錯的Java IDE,有很多插件可以供我們選擇,服務器用Tomcat就行了。安裝好Eclipse和Tomcat之后,還需要兩個插件:tomcat 插件和Struts插件,以下是相關下載地址:
         Eclipse SDK:
            http://www.eclipse.org/downloads/index.php
        Struts:
         https://sourceforge.jp/projects/amateras/files/         StrutsIDE+htmlEditor,htmlEditer也是必要的
        Tomcat :
             http://www.sysdeo.com/eclipse/tomcatplugin
        Plugin Search:
             http://eclipse-plugins.2y.net/eclipse/search.jsp
       插件的安裝和配置有問題請直接Google。
    2.開始
        入門嘛,我們就找一個最簡單的Login就可以了

        新建Tomcat project,如下圖

        加入struts支持
        新建一個FormBean:LoginForm


    /**
     *
     */
    package com.test;

    import javax.servlet.http.HttpServletRequest;

    import org.apache.struts.action.ActionErrors;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.action.ActionMessage;

    /**
     * @author lzy
     *
     */
    public class LoginForm extends ActionForm {

     private String name=null;
     private String password=null;
     /* (non-Javadoc)
      * @see org.apache.struts.action.ActionForm#reset(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
      */
     @Override
     public void reset(ActionMapping arg0, HttpServletRequest arg1) {
      // TODO Auto-generated method stub
      name=null;
      password=null;
     }
     /* (non-Javadoc)
      * @see org.apache.struts.action.ActionForm#validate(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
      */
     @Override
     public ActionErrors validate(ActionMapping arg0, HttpServletRequest arg1) {
      // TODO Auto-generated method stub
    ActionErrors errors=new ActionErrors();
      
      if(name==null||name.length()<1){
       errors.add("username",new ActionMessage("errors.login.name.empty"));
       
      }
      if(password==null||password.length()<1){
       errors.add("password",new ActionMessage("errors.login.password.empty"));
       
      }
      
      return errors;
     }
     /**
      * @return Returns the name.
      */
     public String getName() {
      return name;
     }
     /**
      * @param name The name to set.
      */
     public void setName(String name) {
      this.name = name;
     }
     /**
      * @return Returns the password.
      */
     public String getPassword() {
      return password;
     }
     /**
      * @param password The password to set.
      */
     public void setPassword(String password) {
      this.password = password;
     }
    }

     

     

         新建一個Action:LoginAction

    /**
     *
     */
    package com.test;


    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    import org.apache.struts.*;
    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 org.apache.struts.action.ActionMessage;
    import org.apache.struts.action.ActionMessages;

    /**
     * @author lzy
     *
     */
    public class LoginAction extends Action {
     public ActionForward execute(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception {
      // TODO Auto-generated method stub
      LoginForm loginForm=(LoginForm)actionForm;
      String name=loginForm.getName();
      String password=loginForm.getPassword();


     if(name.equals("name")&&password.equals("password")){
       HttpSession session=request.getSession(true);
       session.setAttribute("LOGGED_USER",name);

       
       return mapping.findForward("success");
       
      }
      else{
       ActionMessages errors=new ActionMessages();
       errors.add("login.failure",new ActionMessage("errors.login.failure")); 
       this.saveErrors(request,errors);
       
       return mapping.findForward("failure"); 
       
      }
      
     }

    }

         新建兩個JSP頁面,login.jsp,index.jsp

    login.jsp
    <%@ page contentType="text/html; charset=GBK" %>
    <%@ taglib uri="/tags/struts-html" prefix="html" %>
    <%@ taglib uri="/tags/struts-tiles" prefix="tiles" %>

    <html:html>
     <head>
      <html:base />
              </head>
     <body>
     <center>
     <html:errors />
      <html:form action="/login.do" method="POST">
      <table border="1">
       <tr>
        <td colspan="2"><bean:message key="login.jsp.form.title"/></td>
       </tr>
       <tr>
        <td align="right"><bean:message key="login.jsp.name"/></td>
        <td><html:text property="name" size="20"></html:text></td>
       </tr>
       <tr>
        <td align="right"><bean:message key="login.jsp.password"/></td>
        <td><html:password property="password" size="20"></html:password></td>
       </tr>
       <tr>
        <td colspan="2">
         <html:submit><bean:message key="form.submit"/></html:submit>
         <html:reset><bean:message key="form.reset"/></html:reset>
        </td>
       </tr>
     
      </table>
     
      </html:form>
      
     </center>
     </body>
    </html:html>


    index.jsp


    <%@ page contentType="text/html; charset=GBK" %>
    <%@ taglib uri="/tags/struts-bean" prefix="bean" %>
    <%@ taglib uri="/tags/struts-logic" prefix="logic" %>
    <%@ taglib uri="/tags/struts-html" prefix="html" %>
    <%@ taglib uri="/tags/struts-nested" prefix="nested" %>

    <html:html>
     <head>
      <meta http-equiv="Content-Type" content="text/html; charset=GBK"/>
      <title></title>
     </head>
     <body>
     hello
      <logic:present name="LOGGED_USER">,<bean:write name="LOGGED_USER"/>
      </logic:present>
     </body>
    </html:html>


         編輯WEB-INF/lib下的struts-config.xml

    struts-config.xml

    <?xml version="1.0"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "<struts-config>
      <data-sources>
      </data-sources>
      <form-beans>
        <form-bean name="loginForm" type="com.lzy.LoginForm"/>
      </form-beans>
      <global-exceptions>
      </global-exceptions>
      <global-forwards>
      </global-forwards>
      <action-mappings>
          <action path="/login" name="loginForm" type="com.lzy.LoginAction" scope="session" validate="true" input="/login.jsp">
          <forward name="failure" path="/login.jsp"/>
          <forward name="success" path="/index.jsp"/>
        </action>
      </action-mappings>
      <controller processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>
      <message-resources parameter="MessageResources"/>

    </struts-config>


           最后是資源文件

    # -- standard errors --
    errors.header=<UL><font color="red"><h2>Errors:</h2>
    errors.prefix=<LI>
    errors.suffix=</LI>
    errors.footer=</font></UL><hr>


    form.submit=Submit

    form.reset=Reset


    # -- login.jsp --
    login.jsp.title=Login
    login.jsp.form.title=Login
    login.jsp.name=Name:
    login.jsp.password=Password:

    # -- login errors --
    errors.login.name.empty=The name can not be empty!
    errors.login.password.empty=The password can not be empty!
    errors.login.failure=Login failed!<br> Please check your username and password!

     

    3.測試
    在test工程中選擇tomcat project->Update context definition
    然后運行Tomcat
    http://127.0.0.1:8080/test/login.jsp


      

    posted @ 2005-12-10 11:10 all gone 閱讀(1215) | 評論 (0)編輯 收藏

    Java Web Service 之SOAP入門

          這幾天在圖書館看到了一本書《Java SOAP編程指南》,出于對正興起的web service的好奇,借了回來。看了一下SOAP的介紹,沒太明白,只知道是Simple Object Access Protocol,和XML結合可以提供跨平臺的服務。
           編程的人總有這么一個愛好,開始的時候總要拿一個HelloWorld似的例子試試,我也不例外。 要試當然要有SOAP的運行環境。按照書上的指示,裝好了Tomcat,下載了相關的包,將soap.jar ,mail.jar,activatio.jar,xercesImpl.jar 加入到了環境變量classpath中,將soap.war拷貝到了TOMCAT的webapps目錄下。
           運行SOAP的測試目錄:HTTP://127.0.0.1:8080/soap/發現soap已經正常工作。 接著便是部署新的SOAP服務了,按照書上的源碼,寫好了測試用的部署類和客戶端類,編譯通過。在部署新的SOAP的web頁面下按照書上的步驟添好表單并部署完成。將測試所在目錄添加到classpath中。 重啟tomcat。 運行剛才編譯好的客戶端類,結果NoClassDefError。
           試了好幾遍,都是這樣,很是讓我郁悶啊。 看了另一本書《java web服務應用開發詳解》終于找到了答案: 運行客戶端測試程序時,***Client.class是在Package test中的 運行時退回到test的上級目錄,java test.***Client 即可。 我想遇到類似問題,還是對java的包不熟悉。

    posted @ 2005-12-09 19:39 all gone 閱讀(618) | 評論 (0)編輯 收藏

    Eclipse 使用小結

             Eclipse,我想任何一個學習Java的人都會知道它,一個很不錯的開發環境,不光能開發基于Java的各種程序,還能做C++開發,比起JBuilder,我覺得Eclipse有過之而無不及,尤其它還是一個開源項目,很多東西都是JBuilder沒有的。    
             Eclipse 是一個基于插件的開發平臺,很多功能都是通過插件來完成的。比如說要做Java圖形界面開發,如使用AWT和SWING的開發,就需要下載相應的插件,因此使用Eclipse時除了基本的Eclipse SDK還需要下載安裝相應的插件。
    下面是一些相關的下載地址:
        Eclipse SDK:
              http://www.eclipse.org/downloads/index.php(v3.1.1)  
      
        SWING+AWT: 
             Visual Editor: http://www.eclipse.org/vep/ (v1.1.0.1 released) 

        Struts: 
             StrutsIDE+htmlEditor: https://sourceforge.jp/projects/amateras/files/( v1.1.7+1.6.7) 
       J2EE: 
             Tomcat : http://www.sysdeo.com/eclipse/tomcatplugin 
             Lomboz: http://forge.objectweb.org/project/showfiles.php?group_id=97 

       JSF:
           faceIDE https://sourceforge.jp/projects/amateras/files/( v1.1.7+1.6.7) 

       Hibernate: 
             Hibernate synchronizer http://hibernatesynch.sourceforge.net

     Plugin Search: 
             http://eclipse-plugins.2y.net/eclipse/search.jsp

    posted @ 2005-12-09 19:38 all gone 閱讀(370) | 評論 (0)編輯 收藏

    JBuilder 開發J2ME程序第一步

    安裝完JBuilder 9 Enterprise版后,看到介紹中說可以支持J2ME的開發,所以想試一下。 因為J2ME需要另外的jdk支持,所以第一步就是安裝相應的wireless toolkit jdk. 相應的jdk可以從sun的官方網站上下載,安裝過程也非常簡單 這里不再詳敘。 安裝完后,將新的jdk添加到JBuilder的配置中,Tools->Configure JDKs 之后,新建工程,選擇剛才的jdk。 打開Project->Project Properties,在run 選項卡中點New 在彈出框中選擇run, type改為MIDlet(原來為Application)。 之后就可以新建MIDlet了。

    posted @ 2005-12-09 19:33 all gone 閱讀(253) | 評論 (0)編輯 收藏

    JSP實現留言板的JavaBean類和分頁顯示的源碼

     

    //留言bean
    package userinfobean;

    /**
     * <p>Title: </p>
     * <p>Description: </p>
     * <p>Copyright: Copyright (c) 2004</p>
     * <p>Company: </p>
     * @author not attributable
     * @version 1.0
     */

    public class memoBean {

      private String id;//1.用戶名
      private String email;//2.密碼
      private String content;//3.留言 

      public memoBean() {
      }
      //1.用戶名
      public void setId(String s){
        this.id=s;
      }
      //2.密碼
      public void setEmail(String s){
        this.email=s;
      }
      //3.留言
       public void setContent(String s){
        this.content=s;
      }
     

      //1.用戶名
       public String getId( ){
         return this.id;
       }
       //2.密碼
       public String getEmail(){
         return this.email;
       }
       //3.留言 
       public String getContent(){
         return this.content;
       }
    }
    //// 用于數據庫操作的bean          
    package userinfobean;

    import userinfobean.*;
    import java.io.*;
    import java.util.*;
    import java.sql.*;


    public class databaseBean{
      private String dbName;
      private String dbUser;
      private String dbPass;
       private Vector memoVector;

       Connection connection;

      public databaseBean(){
        dbName=new String("×××××××");
        dbUser=new String("××××××");
        dbPass=new String("×××××××");
        String connectionUrl="jdbc:mysql://localhost/"+dbName;
        try{
          Class.forName("org.gjt.mm.mysql.Driver");
          connection=DriverManager.getConnection(connectionUrl,dbUser,dbPass);
        }
        catch(Exception e){
          System.out.println(e.toString());
          }
      }

      public void dbQueryMemos(){
        try{
           memoVector=new Vector();
          Statement stmt=connection.createStatement();
          ResultSet rs=stmt.executeQuery("select * from memo;");
          while(rs.next()){
            memoBean temp=new memoBean();
            temp.setId(rs.getString(2));
            temp.setEmail(rs.getString(3));
            temp.setContent(rs.getString(4));
            memoVector.add(temp);
          }

       }
       catch(SQLException e){
         System.out.println(e.toString());
       }

     

      }

        public void setDbName(String s){
        this.dbName=s;
      }
      public void setDbUser(String s){
        this.dbUser=s;
      }
      public void setDbPass(String s){
        this.dbPass=s;
      }

      public String getDbName(){
        return this.dbName;
      }
      public String getDbUser(){
        return this.dbUser;
      }
      public String getDbPass(){
        return this.dbPass;
      }
        public Vector getMemoVector(){
        return this.memoVector;

      }

    }

    ///以下是網頁源碼

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <%@ page language="java" import="java.util.*" %>
    <%@ page  import="java.text.*" %>
    <%@ page  import="userinfobean.*" %>
    <jsp:useBean id="memoInfo" scope="page" class="userinfobean.memoBean"/>
    <jsp:useBean id="memoQuery" scope="page" class="userinfobean.databaseBean"/>
    <%!
    int totalPages;
    int countPerPage=3;
    int totalCount;
    int currentPage=0;
    int currentStart;
    %>
    <%
    memoQuery.dbQueryMemos();
    Vector vt=memoQuery.getMemoVector();
    totalCount=vt.size();
    totalPages=totalCount/countPerPage;
    if(totalCount%countPerPage>0)totalPages=totalPages+1;
    if(request.getParameter("page")==null)
    {
    currentPage=1;
    }
    else
    {
    currentPage=Integer.parseInt(request.getParameter("page"));
    if(currentPage>totalPages)currentPage=totalPages;
    if(currentPage<1)currentPage=1;
    }
    currentStart=totalCount-1-countPerPage * (currentPage-1);
    %>
    <html>
    <head>
    <title>NetGreen</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
      <link rel="stylesheet" href="main.css">                            
    </head>
    <script language="JavaScript" >
    function page_check()
    {
    if(document.pageForm.page.value=="")
    {alert("請輸入頁數");
    document.pageForm.page.focus();
    return false;
    }
    return true;
    }</script>
    <body bgcolor="ffffff"  >

    <center>
      <table width="800" border="0" height="622">
        <tr>
          <td height="71" align="center" valign="middle"> <table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#0099CC">
              <tr>
                <td width="19%" height="60" align="left" valign="bottom" bgcolor="#FFFFFF"><b><font size="4" color="#00cc66" ><img src="image/logo.gif" width="156" height="60"></font></b></td>
                <td width="57%" align="left" valign="bottom" bgcolor="#FFFFFF"><img src="image/banner.gif" width="100%" height="60"></td>
                <td width="24%" align="left" valign="bottom"> <table width="102%" height="60" border="1" cellpadding="0" cellspacing="0" bordercolor="#0099CC" bgcolor="#FFFFFF">
                    <tr>
                      <td width="50%" height="27" align="center">上 傳</td>
                      <td width="50%" align="center">收藏本頁</td>
                    </tr>
                    <tr>
                      <td height="21" align="center" bgcolor="#FFFFFF" >退 出 </td>
                      <td align="center"><a href="memoForm.htm" target="_self">我要留言</a></td>
                    </tr>
                  </table></td>
              </tr>
            </table></td>
        </tr>
        <tr>
          <td height="31"><table width="100%" border="1" bordercolor="#0099CC">
              <tr bgcolor="#00CC66">
                <td width="12%" height="23" align="center" bgcolor="#CCFFFF"><a href="index.htm" >首頁</a></td>
                <td width="12%" align="center" bgcolor="#CCFFFF"><a href="loginForm.htm" >登陸</a></td>
                <td width="12%" align="center" bgcolor="#CCFFFF">&nbsp;</td>
                <td width="12%" align="center" bgcolor="#CCFFFF">&nbsp;</td>
                <td width="12%" align="center" bgcolor="#CCFFFF" >&nbsp; </td>
                <td width="12%" align="center" bgcolor="#CCFFFF">&nbsp;</td>
                <td width="12%" align="center" bgcolor="#CCFFFF"><a href="memoDisplay.jsp" >留言板</a></td>
                <td width="12%" align="center"  bgcolor="#CCFFFF"><a href="registForm.htm">注冊</a></td>
              </tr>
            </table></td>
        </tr>
        <tr>
          <td height="435" align="center" valign="top" nowrap>
            <table width="100%"  border="1" cellpadding="0" cellspacing="0" bordercolor="#0099CC">
              <tr>
                <td width="18%" height="431" align="center" valign="middle" bgcolor="#CCFFFF">
                </td>
                <td width="83%" align="center" valign="top" bgcolor="#FFFFFF"><table width="100%" border="1"><form name="pageForm" method="post"  onSubmit="return page_check();"action="memoDisplay.jsp">
                    <tr>
                      <td width="36%">共有留言<%out.print(totalPages);%> 頁,現在是第<%out.print(currentPage);%>  頁</td>
                        <td width="64%">
         <a href="memoDisplay.jsp?page=<%=currentPage-1%>" >上一頁 </a>
         <a href="memoDisplay.jsp?page=<%=currentPage+1%>" >下一頁  </a>
         <a href="memoDisplay.jsp?page=1" >首頁 </a>
          <a href="memoDisplay.jsp?page=<%=totalPages%>" >尾頁  </a>
          <input type="submit" name="Submit" value="G0">
                          <input name="page" type="text" size="10">
                          頁</td>
                    </tr>
                  </form></table>
                  <%
        
        for(int i=0;i<countPerPage&&currentStart-i>=0;i++)
        {
         memoInfo.setId(((memoBean)vt.get(currentStart-i)).getId());
         memoInfo.setEmail(((memoBean)vt.get(currentStart-i)).getEmail());
         memoInfo.setContent(((memoBean)vt.get(currentStart-i)).getContent());
         
         
         
       out.print("<table width='100%' border='1' ><tr><td width='19%'>");
       out.print(memoInfo.getId());
       out.print("</td><td width='81%'>");
       out.print(memoInfo.getEmail());
       out.print("</td></tr><tr><td height='44' colspan='2'>");
       out.print(memoInfo.getContent());
       out.print("</td></tr></table> ");
       out.print("<br>");
         
        }
      
       %>
       </td>
              </tr>
            </table>
          </td>
        </tr>
        <tr>
          <td height="73" align="center" valign="top" nowrap>
            <table width="100%" border="0">
              <tr>
                <td height="21" align="center" bgcolor="#FFFFFF"><hr width="85%" noshade  color="#00CC66"></td>
              </tr>
              <tr>
                <td height="12" align="center">Copyright @ HomeLee. All rights reserved.
                </td>
              </tr>
              <tr>
                <td height="12" align="center" bgcolor="#FFFFFF">&nbsp;</td>
              </tr>
            </table></td>
        </tr>
      </table>
      </center></body>
    </html>

    posted @ 2005-12-09 19:30 all gone 閱讀(515) | 評論 (1)編輯 收藏

    JDBC連接MySQL數據庫

    Step1:
          查找驅動程序 MySQL目前提供的java驅動程序為Connection/J,可以從MySQL官方網站下載,并找到mysql-connector-java-3.0.15-ga-bin.jar文件,此驅動程序為純java驅動程序,不需做其他配置。
    Step2:
          動態指定classpath 如果需要執行時動態指定classpath,就在執行時采用-cp方式。否則將上面的.jar文件加入到classpath環境變量中。
     Step3:
          加載驅動程序
           try{ 
                   Class.forName("com.mysql.jdbc.Driver"); 
                    System.out.println("Success loading Mysql Driver!"); 
           } 
          catch(Exception e) { 
                   System.out.println("Error loading Mysql Driver!");
                    e.printStackTrace(); 
            }
    Step4:
            設置連接的url jdbc:mysql://localhost/databasename[?pa=va][&pa=va]

    posted @ 2005-12-09 19:29 all gone 閱讀(386) | 評論 (0)編輯 收藏

    FreeBSD5.3下安裝Apache+PHP+MySQL+Tomcat

    以前有過在linux下裝Apache+PHP+MySQL的經驗,這幾天裝了FreeBSD,我想在下面也裝個數據庫玩玩,當然首選MySQL了,這個簡單呀.
    1.MySQL
    找到了/usr/ports/databases/mysql50-server
    cd /usr/ports/databases/mysql50-server
    make install clean
    之后的數據庫并沒有生成
    需要添加用戶mysql:mysql
    運行mysql_install_db
    就會發現在/var/db下生成了mysql目錄,里面就是mysql的數據庫文件了
    chown -R mysql:mysql /var/db/mysql
    在rc.conf中加入mysql_enable="YES"
    /usr/local/etc/rc.d/mysql-server.sh -start
    如果沒有錯誤的話mysql就運行了

    裝了這個當然掛個服務器測試測試了
    2.Apache
    cd /usr/ports/www/apache20/
    以前在linux下裝的時候有個參數--enable-so
    我給加到了Makefile里,不知道有沒有必要,反正后來也裝好了
    make install clean
    安裝成功
    修改一下配置文件httpd.conf
    在rc.conf中加入apache2_enable="YES"
    /usr/local/etc/rc.d/apache2.sh start
    啟動成功的話也就可以了

    3.PHP
    cd /usr/ports/www/mod_php5
    make install clean
    安裝的時候選中那個with apache什么的就可以了
    安裝后將httpd.conf中的loadmodule 最后一個剛加進去的php的#去掉
    Addtype 行加入.php .phps
    寫一個phpinfo()測試一下就可以了

    4.PHP+MySQL
    裝mod_php5的時候沒有加入mysql支持
    cd /usr/ports/databases/php5-mysql
    make install clean就可以了

    到此就架好了Apache+PHP+MySQL
    5.安裝Tomcat
    以前裝好了jdk-1.4.2 裝Tomcat之前unset JAVA_HOME
    cd /usr/ports/www/jakarta-tomcat5
    make install clean就可以了
    /usr/local/bin/tomcat50ctl start

    http://127.0.0.1:8180/
    測試通過
    6.Tomcat+MySQL
    mysql的官方網站下一個聯接器,將相應的jar文件放到
    tomcat相應目錄下
    7.Apache + Tomcat
    我剛開始的時候裝了mod_jk2-apache2
    結果沒有成功,又裝mod_jk-apache2,也沒有成功啊
    后來想起在windows下成功過,去看了看,發現用的是mod_jk2
    沒辦法,又回去裝了mod_jk2-apache2
    將httpd.conf中加載mod_jk2的行啟用

    之后我將windows下的workers2.properties文件拷到了
    /usr/local/etc/apache2下,只做了一處修改
    以下是修改后的:
    [shm]
    info=Scoreboard. Requried for reconfiguration and status with multiprocess servers.
    file=/var/log/shm.file
    size=1048576

    # Defines a load balancer named lb. Use even if you only have one machine.
    [lb:lb]

    # Example socket channel, override port and host.
    [channel.socket:localhost:8009]
    port=8009
    host=localhost

    # define the worker
    [ajp13:localhost:8009]
    channel=channel.socket:localhost:8009
    group=lb

    # Map the Tomcat examples webapp to the Web server uri space
    [uri:/examples/*]
    group=lb

    [uri:/admin/*]
    group=lb


    [status:]
    info=Status worker, displays runtime information

    [uri:/jkstatus/*]
    info=The Tomcat /jkstatus handler
    group=status:

    [uri:/*.jsp]
    worker=ajp13:localhost:8009

    之后touch /var/log/shm.file創建shm.file
    chown -R www:www var/log/shm.file

    之后重啟ApacheTomcat
    測試:http://127.0.0.1/index.jsp

    發現成功了

    呵呵,大功告成 

    posted @ 2005-12-09 19:28 all gone 閱讀(336) | 評論 (0)編輯 收藏

    RedHat 9:Linux下安裝mplayer播放器

    Red Hat 9:Linux下安裝mplayer播放器
     

    在Linux RH9下安裝mplayer很多次了,以前都是以失敗而告終,前兩天終于裝成功了,為自己感到慶幸。大家以后安裝的時候可以作為一個參考(有些地方我也是參考別人的)。

    mplayer是linux下播放速度最快(正確安裝了顯卡驅動),支持媒體格式最多的播放器之一 ,它幾乎能播放所有的win媒體文件!下面介紹它的安裝方法:


    安裝大前提:
    要編譯這個軟件,確認你系統安裝了相應的XFree86-devel,還有如果你要編譯gui操作界面
    (./configure --enable-gui),還請確認你的系統有libpng,libpng-devel,gtk和
    gtk-devel(要求版本大于1.2)這四個軟件,可以在www.rpmfind.net找到相應的rpm包
    (這些包通過安裝Gnome桌面可以獲得)
    1、在下載mplayer的最新版本及安裝所需軟件包的集合包

    2、升級gcc: (必要,推薦gcc版本為2.9.5和3.2.x)
    檢查你的gcc版本,運行gcc -v看輸出是多少,如果是3.0以下的話,則建議安裝gcc3.0以
    上(根據mplayer的官方說明,3.0以下的gcc可以用./configre --disable-gcc-checking
    參數編譯,但可能不穩定),安裝gcc3的方法是:進入gcc3目錄,運行rpm -ivh *.rpm
    --nodeps,全部百分百安裝后,開一個終端窗口,運行mv /usr/bin/gcc /usr/bin/gcc2
    和mv /usr/bin/gcc3 /usr/bin/gcc,再運行gcc -v,看輸出是否為3.0.2,如果是,則ok ,不是,則檢查安裝步驟。 

    3、編譯安裝mplayer:
    tar vxf MPlayer-****.tar,cd MPlayer-****,./configure (如果你想
    要gui的操作界面,則換用這個命令./configrue --enable-gui,但似乎這個版本的gui編
    譯有錯,我和linuxCN都無法成功,pre4版本則沒問題),make,make
    install,都成功運行一下mplayer(這是為了讓它在家目錄下建立.mplayer這個配置目錄
    (.mplayer為隱藏目錄,用ls -a指令可以看見,cd ~/.mplayer指令可以進入),好進行下一
    步操作)

    ./configure --prefix=/usr/local --enable-gui  --enable-live --enable-menu --enable-freetype --enable-fontconfig  --enable-win32 --enable-dshow --enable-real --enable-divx4linux --enable-xvid --disable-arts --language=zh_CN --enable-dynamic-plugins --with-codecsdir=/usr/local/lib/codecs --with-win32libdir=/usr/local/lib/codecs --with-reallibdir=/usr/local/lib/codecs --with-livelibdir=/usr/local/lib/live  --with-freetype-config=/usr/bin/freetype-config
    重要參數說明:
    --prefix=             安裝路徑為/usr/local
    --enable-gui          使用圖形界面,mplayer有命令行和圖形界面兩種運行方式
    --enable-live         使用流媒體支持
    --enable-freetype     字幕字體可以使用ttf字體
    --enable-win32        可以使用win32的.dll格式的解碼器
    --enable-real         支持real格式
    --language=zh_CN      mplayer界面的格式為中文
    --with-codecsdir=/usr/local/lib/codecs         指定解碼器搜索路徑
    --with-win32libdir=/usr/local/lib/codecs       指定win32解碼器搜索路徑
    --with-reallibdir=/usr/local/lib/codecs        指定real解碼器搜索路徑
    --with-livelibdir=/usr/local/lib/live          指定live解碼器搜索路徑

    現在使用
    make
    自動編譯軟件,可以去吃飯,回來再看 

    make install             //安裝

    運行mplayer
    ./mplayer


    4、拷貝配置文件:(注意:下面這個etc目錄是上一步中解壓出來的MPlayer-***目 錄下的,非/etc)
    cp etc/codecs.conf ~/.mplayer
    cp etc/example.conf ~/.mplayer/config

    5、安裝font和skin:(如果你選擇了./configure --enable-gui那才需要skin,否則skin
    不用安裝)
    進入自己的home目錄,顯示隱藏文件,進入.mplayer文件夾,創2個建文件夾:font和
    Skin。

    下載font文件,(mplayer官方網站上有)拷入到font內拷貝simsun.ttf到~/.mplayer目錄中
    拷貝Blue皮膚目錄到/usr/local/share/mplayer/Skins目錄中

    6、運行方式
    兩種:(1)mplayer /路徑/要播放的媒體文件名;(2)gmplayer(只有用./configure
    --enable-gui編譯的這個命令才有效)

    現在可以運行mplayer和gmplayer了。但是gmplayer字幕出現問題,提示找不到

    字幕字體文件。按照提示拷貝simsun.ttf(其他字體文件也可以)到~/.mplayer目錄中(改文件名)。

    7、關于~/.mplayer/config文件的一些配置說明
    vo=xv(選擇默認的播放模式,xv模式是支持顯卡硬加速功能的模式,對cpu的占用很小,
    推薦;更多的顯示模式可以用命令mplayer -vo help看,其中的vesa模式可以在不啟動
    xwin界面時播放,有點象當年DOS下的金山影霸)
    ao=oss(選擇聲音的播放模式,oss是兼容性最好的播放模式,推薦;你也可以試試sdl模
    式)
    fs=yes(全屏模式,yes的話默認以全屏播放,no或前面加#號注釋掉這行的話則默認是1
    :1播放模式)
    zoom=yes(即時改變電影畫面大小,yes的話則可以用鼠標隨意將播放畫面拉大拉小,no
    的話不能)
    gui = yes(默認是圖形化操作界面,這需要你先前用./configure --enable-gui來編譯
    ,否則的話就算yes也沒有gui操作界面)
    skin = default(設置默認的skin,將等號右邊的值換成skin所放目錄就可以設置想要的
    skin為默認了,這個參數在用gui操作界面才有效)
    cache = 8192(默認的播放緩存大小,如果機器內存夠大,則將它加大一點,如果不是很
    大,譬如128以下,還是用默認的算了)
    framedrop = yes(允許跳幀,如果你的機器CPU速度非常非常慢的話請將這個yes,默認
    是no或前面加#號將這行禁止;對于366MHZ以上的機器,建議都設成no或前面加#號)
    其他設置用默認就行 。

    posted @ 2005-12-09 19:25 all gone 閱讀(1441) | 評論 (1)編輯 收藏

    RH9下安裝apache2.x.x+php4.x.x+mysql3.x.x

    ******************************************************************************

    先安裝Mysql
    ******************************************************************************

    shell> groupadd mysql
    shell> useradd -g mysql mysql
    shell> gunzip < mysql-VERSION.tar.gz | tar -xvf -
    shell> cd mysql-VERSION
    shell> ./configure --prefix=/usr/local/mysql
    shell> make
    shell> make install
    shell> cp support-files/my-medium.cnf /etc/my.cnf
    shell> cd /usr/local/mysql
    shell> bin/mysql_install_db


    shell> chown -R root .
    shell> chown -R mysql var
    shell> chgrp -R mysql .
    shell> bin/mysqld_safe --user=mysql &

    ******************************************************************************

    再安裝PHP和apache
    ******************************************************************************

    1. gzip -d httpd-2_0_NN.tar.gz
    2. tar xvf httpd-2_0_NN.tar
    3. gunzip php-NN.tar.gz
    4. tar -xvf php-NN.tar
    5. cd httpd-2_0_NN
    6. ./configure --enable-so
    7. make
    8. make install
    現在您已經將 Apache 2.0.NN 安裝在 /usr/local/apache。本安裝支持可裝載模塊
    和標準的 MPM prefork。之后,可以使用如下命令啟動 Apache 服務器:
    /usr/local/apache2/bin/apachectl start
    如果成功,您可以停止 Apache 服務器并繼續安裝 PHP:
    /usr/local/apache2/bin/apachectl stop.
    9. cd ../php4-NN


    10. 現在我們需要配置 PHP。在這里您可以用各種各樣的參數來自定義PHP,例如啟動哪
    些擴展功能包的支持等。用 ./configure --help 命令可以列出當前可用的所有參
    數。在我們的例子中,我們將給出一個在有 MySQL 支持的 Apache 2 上進行配置的
    范例。您本地的 apxs 的路徑可能會不同,事實上,在您的系統中,它可能被命名為
    apxs2。
    ./configure --with-apxs2=/usr/local/apache2/bin/apxs
    11. make
    12. make install
    如果您決定在安裝后改變配置選項,您只需重復最后的三步,然后需要重新啟動
    Apache 使新模塊生效。無需重新編譯。
    請注意,除非明確有提示,否則 'make install' 命令將安裝 PEAR、各種 PHP 工具
    諸如 phpize,安裝 PHP CLI 等等。
    13. 配置 php.ini
    cp php.ini-dist /usr/local/lib/php.ini
    您可以編輯 php.ini 文件以修改 PHP 的選項。如果您想要把此文件放到另外的位置,
    您需要在步驟 10 添加 --with-config-file-path=/path 選項。
    如果您選擇 php.ini -recommended,請務必閱讀其中的變更的列表,它們將影響
    PHP 的執行。
    14. 編輯 httpd.conf 文件以調用 PHP 模塊。LoadMolude 表達式右邊的路徑必須指向您

    系統中的 PHP。以上的 make install 命令可能已經幫您完成了這些,但務必要檢查。
    對于 PHP 4:
    LoadModule php4_module modules/libphp4.so


    對于 PHP 5:
    LoadModule php5_module modules/libphp5.so
    15. 告知 Apache 將特定的擴展名解析成 PHP,例如,我們讓 Apache 將擴展名 .php
    解析成 PHP。您可以將任何擴展名指定為 PHP,只需添加它們,每一個用空格分隔。
    例如,我們要添加 .phtml:
    AddType application/x-httpd-php .php .phtml
    通常,我們還將 .phps 擴展名設置成顯示高亮的 PHP 源文件,可以這樣來完成:
    AddType application/x-httpd-php-source .phps
    16. 啟動您的 Apache 服務器:
    /usr/local/apache2/bin/apachectl start

    按照上面的步驟您便可以使 Apache 2.0 將 PHP 作為 SAPI 模塊了。當然 Apache 和
    PHP 都還有很多配置選項,您可以在相應的源代碼目錄中使用 ./configure --help 獲得

    更多信息。假如您要編譯一個多線程版本的 Apache 2.0,您必須覆蓋標準的
    MPM-Module
    prefork,或者 worker 或者 perchild。要這樣,您需要在上面的第 6 步使用
    --with-mpm=worker 或者 --with-mpm=perchild 選項。之前您需要了解您正在做什么。

    多信息請參考 Apache 文檔中關于 MPM-Modules 的部分。

    posted @ 2005-12-09 19:23 all gone 閱讀(244) | 評論 (0)編輯 收藏

    Linux下編寫OpenGL程序的一些準備工作

    linux下編寫OpenGL程序的一些準備工作

    需要用到的軟件包有兩個,glut 和tmake,分別可以從以下兩個網址下載:
    http://www.opengl.org/resources/libraries/glut/glut-3.7.tar.gz
    ftp://ftp.trolltech.com/freebies/tmake/tmake-1.8.tar.gz

    下載后的文件假設都放在/usr/src中

    首先是安裝glut庫,以下是從www.linux.com找到的編譯glut庫的手冊。

    Install GLUT 3.7 Distribution (optional)

    If you installed the MesaDemos/MesaLib package, then you have already installed GLUT 3.7 since it is included with MesaDemos. However, you may be interested in installing the GLUT

    manpages and you can skip right to the "Install GLUT manual pages", below ...

    Installing GLUT is a bit tricky. I'm not too familiar with imake, the program that it uses to manage the Makefiles, and didn't quite see how to get GLUT to install to where I wanted it (/usr/lib,

    but MesaDemos will do this without any trouble though). It can be done manually anyhow:

     cd /usr/src
     tar -xvzf glut-3.7.tar.gz
     cd glut-3.7

     Read the file: README.linux
     cd linux
     READ the file: README
     cp Glut.cf ..
     cd ..
     Edit Glut.cf: remove any Mesa references.
     Replace any -lMesaGL -lMesaGLU with -lGL -lGLU if needed.
     In particular, replace:
      OPENGL = $(TOP)/../lib/libMesaGL.so
      GLU = $(TOP)/../lib/libMesaGLU.so
     with:
      OPENGL = -lGL
      GLU = -lGLU

     ./mkmkfiles.imake
     cd lib/glut
     cp /usr/src/glut-3.7/linux/Makefile .
     Edit the Makefile: remove any Mesa references.
     Replace any -lMesaGL -lMesaGLU with -lGL -lGLU if needed.
     In particular, replace:
      OPENGL = $(TOP)/../lib/libMesaGL.so
      GLU = $(TOP)/../lib/libMesaGLU.so
     with:
      OPENGL = -lGL
      GLU = -lGLU

     make
     ln -s libglut.so.3.7 libglut.so
     ln -s libglut.so.3.7 libglut.so.3
     cp -d libglut.* /usr/lib
     cd ..
     cd gle
     # make a shared lib for libgle
     make
     gcc -shared -o libgle.so.3.7 *.o
     ln -s libgle.so.3.7 libgle.so
     ln -s libgle.so.3.7 libgle.so.3
     cp -d libgle.* /usr/lib
     cd ..
     cd mui
     # make a shared lib for libmui
     make
     gcc -shared -o libmui.so.3.7 *.o
     ln -s libmui.so.3.7 libmui.so
     ln -s libmui.so.3.7 libmui.so.3
     cp -d libmui.* /usr/lib

            # Install the GLUT manual pages (not included with MesaDemos)
     cd /usr/src/glut-3.7
     make SUBDIRS=man Makefile
     cd man/glut
     make install.man
     ldconfig

     cd ../../progs/demos/ideas
     # edit the Makefile, change OPENGL = -lGL and GLU = -lGLU
     make
     ./ideas
     # test compiling some demos
     # take a look at which libraries have to be linked (-lX11 ...) in
     # the Makefiles.  Qt's tmake program available at www.troll.no
     # is a quick way to make a Makefile but you have to edit it
     # and add the -l needed.
    ideas如果運行成功的話,說明glut已經可以用了,這時可以將include/GL下的glut等頭文件復制到/usr/include中去。

    上面的幾步中,下載的glut包放在/usr/src目錄下,如果放在其他目錄下,將/usr/src改為相應的目錄即可。
    此外應該注意的是兩個Makefile文件的修改
     改 
    ·  OPENGL = $(TOP)/../lib/libMesaGL.so
      GLU = $(TOP)/../lib/libMesaGLU.so
     為
      OPENGL = -lGL
      GLU = -lGLU
    因為所指定的目錄中沒有libMesaGL.so和libMesaGLU.so。

    之后是tmake的配置,后面我們可以用它來生成pro工程文件和makefile文件。

    先將下載的tmake解壓縮,tar  -zxvf  tmake-1.8.tar.gz
    得到tmake-1.8目錄,之后設置兩個環境變量:PATH和TMAKEPATH
    PATH=$PATH:/usr/src/tmake-1.8/bin
    export PATH
    TMAKEPATH=/usr/src/tmake-1.8/lib/linux-g++
    export TMAKEPATH

    新建一個測試目錄test,將glut-3.7目錄下的progs/redbook目錄下的hello.c復制到test目錄中

    之后生成一個pro文件:progen  -o hello.pro

    然后生成makefile文件:tmake hello.pro -o Makefile

    編輯生成的Makefile文件,在加載動態連接庫的行里面加入 -lglut -lXi -lXmu

    保存,make。

    ./hello 可以看到運行結果就可以了。

    posted @ 2005-12-09 19:22 all gone 閱讀(632) | 評論 (0)編輯 收藏

    FreeBSD下OpenGL程序的問題

    五一期間裝了個FreeBSD,5.3 release,KDE桌面,感覺還是不錯

    前些天在Redhat Linux弄過OpenGL的開發環境,那時是自己編譯的glut庫,然后用tmake編寫makefile,感覺很方便。

    五一期間裝了個FreeBSD,5.3 release,KDE桌面,感覺還是不錯的,用多了感覺圖形界面都快趕上WindowsXP了。

    還是入正題吧。我想試試glut,pkg_info|grep glut

    發現有個libglut.6...的,是支持OpenGL的,不知道是不是我想要的glut.

    查找libglut.so,發現在/usr/X11R6/lib里面了,版本3,對頭。

    把在linux里用過的tmake,和opengl redbook源碼拷了過來,設置好tmake相關的環境變量

    當然最重要的是改相應的tmake.conf文件了,將glut相關的庫加進去

    新建目錄test,將hello.c拷進去,

    progen -o hello.pro

    tmake hello.pro "CONFIG+=opengl" -o Makefile

    可以先檢查一下生成的Makefile,我沒有發現問題

    make,成功,生成可執行的hello

    ./hello出現一新窗口,本來應該高興的,卻有點不對勁,窗口上什么也沒話

    而且是白色背景,應該是黑色背景然后畫一個白色的正方形。

    google了好久,終于發現有人跟我遇到過同樣的問題

    解決的方法很簡單 link的時候加上 -pthread選項,我先改了一下生成的Makefile,加上了-pthread

    make,也通過了,看來問題有可能解決了

    ./hello 終于正確的結果出現了

    posted @ 2005-12-09 19:20 all gone 閱讀(520) | 評論 (0)編輯 收藏

    tmake&Qt開發

    使用tmake生成Qt程序的makefile文件

    使用tmake生成Qt程序的makefile文件真的是很簡單,本來tmake就是發布Qt那個公司的產品啊. 自己編寫.h和.cpp文件時,tmake的用法可以在安裝文檔里找到. 使用Qt Designer時呢,生成的是.ui文件,這時也可以用tmake的: 假設生成的.ui文件名為mainform.ui,自己寫一個簡單的main.cpp文件:

    #include "mainform.h"

    int main(int argc,char **argv)

     {

    QApplication app(argc,argv);

    MainForm mainform;

    app.setMainWidget(&mainform);

     mainform.show();

    return app.exec();

    }

    接下來就可以使用tmake了

    progen -o main.pro

     tmake main.pro -o Makefile

     make

     ./main 呵呵,可以了

    posted @ 2005-12-09 19:18 all gone 閱讀(521) | 評論 (0)編輯 收藏

    主站蜘蛛池模板: 国产福利免费在线观看| 亚洲人成网男女大片在线播放| 四虎永久在线精品免费网址| 两个人日本免费完整版在线观看1| 亚洲精品一二三区| 久久亚洲AV成人无码电影| 亚洲伊人久久综合影院| 国产免费啪嗒啪嗒视频看看| 中国在线观看免费高清完整版| 久久久久国产精品免费免费不卡| 全部在线播放免费毛片| 国产精品亚洲精品久久精品 | 精品亚洲国产成人av| 亚洲一级在线观看| 亚洲综合视频在线| 亚洲AV无码精品色午夜果冻不卡| 亚洲精品乱码久久久久久蜜桃| 小小影视日本动漫观看免费| 成人午夜18免费看| 国产成在线观看免费视频| 永久看日本大片免费35分钟 | 亚洲综合国产精品| 久久亚洲一区二区| 亚洲国产精品一区二区第一页| 久久久久亚洲AV无码专区桃色| 亚洲成aⅴ人片久青草影院| 日本无吗免费一二区| 国内自产拍自a免费毛片| 成全视频在线观看免费高清动漫视频下载| 91频在线观看免费大全| 18禁网站免费无遮挡无码中文| 最近免费中文字幕大全免费版视频 | 2020因为爱你带字幕免费观看全集 | 东方aⅴ免费观看久久av| aaa毛片免费观看| 中国极品美軳免费观看| 中文精品人人永久免费 | 精品亚洲麻豆1区2区3区| 久久精品国产精品亚洲毛片| 亚洲国产成人手机在线电影bd| 亚洲Av无码一区二区二三区|