2005年12月9日
#
- 基本包的安裝
sudo apt-get install tetex-base tetex-bin tetex-extra
- CJK包安裝
sudo apt-get install latex-cjk-chinese
- CJK UTF8字體生成
將下面的code復(fù)制到文件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
根據(jù)自己的需要可以將TEXMFHOME目錄設(shè)置成不同的地方,只要Latex能找到即可
我將該目錄改為了/usr/share/texmf-tetex,如果相應(yīng)的目錄不存在,則需要自己新建。
將windows系統(tǒng)中的字體文件拷到腳本所在目錄執(zhí)行腳本即可生成Latex所需字體文件,以simhei.ttf為例:
sudo ./cvtfont.sh simhei.ttf simhei simhei
摘要: 很久沒有看Java相關(guān)的東西了,這幾天才發(fā)現(xiàn)Struts2 已經(jīng)發(fā)布了,以前就聽說(shuō)Struts2就是以前的Webwork2,只是作了少許的改動(dòng)而已,我以前也沒看過Webwork,所以趕緊下來(lái)試了一把。Struts2的地址:http://struts.apache.org/2.x在Eclipse中新建了一個(gè)Tomcat工程(如果用WTP插件的話Dynamic Web工程)struts2Test,以下...
閱讀全文
前幾天按照Ubuntu How-To上的NVIDIA驅(qū)動(dòng)安裝說(shuō)明安裝了8672版的驅(qū)動(dòng),結(jié)果發(fā)現(xiàn)只要退出X-Window,系統(tǒng)就會(huì)沒有反應(yīng),網(wǎng)上搜了搜,發(fā)現(xiàn)有人也有一樣的情況,按照說(shuō)明重新安裝、重新配置Xorg,問題依然沒有解決,X-Window也起不來(lái)了。
到NVIDIA網(wǎng)站上下了最新的8774版驅(qū)動(dòng)后,趕緊找找看怎么自己裝,有人已經(jīng)寫好了
在恢復(fù)模式下:
需要gcc支持,如果沒有安裝則:
apt-get install build-essential gcc
刪除已經(jīng)安裝的NVIDIA驅(qū)動(dòng):
apt-get --purge remove linux-restricted-modules-`uname -r` linux-restricted-modules-common nvidia-glx nvidia-settings nvidia-kernel-common
安裝內(nèi)核headers
apt-get install linux-headers-`uname -r`
將下載下來(lái)的NVIDIA-Linux-x86-1.0-8774-pkg1.run解壓縮:
sh ./NVIDIA-Linux-x86-1.0-8774-pkg1.run --extract-only
進(jìn)入解壓后的NVIDIA-Linux-x86-1.0-8774-pkg1文件夾,執(zhí)行安裝:
./nvidia-installer -n --x-prefix=/usr/lib/xorg/
最后由于默認(rèn)安裝到了/usr/lib/xorg/lig/xorg,需要將文件拷到對(duì)應(yīng)的目錄下:
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/
前天剛裝了個(gè)Qt4for windows,發(fā)現(xiàn)安裝的時(shí)候MySQL等數(shù)據(jù)庫(kù)插件都沒有安裝,像Qt X11版一樣,都需要自己安裝這些插件。
在Qt的安裝目錄C:\Qt4.1.2\下,有個(gè)src目錄,進(jìn)入plugins\sqldrivers\mysql,可以看到兩個(gè)文件,main.cpp和mysql.pro,很顯然要用qmake來(lái)完成編譯、生成目標(biāo)。
編譯前,首先保證依賴的MySQL頭文件和庫(kù)文件正確。首先MySQL安裝目錄下的include中的所有文件拷到qmake時(shí)能找到的目錄下,接著從lib/opt目錄下拷出libmysql.a,其實(shí)lib/opt下只有l(wèi)ibmysql.lib和libmysql.dll,從網(wǎng)上搜了一下找到一個(gè)方法從libmysql.dll生成libmysql.a:
1 、安裝好MySQL (如果不愿意安裝,找個(gè)libmySQL.dll文件也可以)
2、下載Pexports工具
3、轉(zhuǎn)換操作: pexports libmysql.dll > libmysql.def
4、使用MinGW的 dlltool轉(zhuǎn)換成為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
如果再出現(xiàn)象mysql_connect@xx (xx是數(shù)字)的錯(cuò)誤提示。就執(zhí)行第6步。
6、修改libmysql.def文件,給mysql_connect加上@xx,即mysql_connect@xx
7、重做第4步
8、然后嘗試第5步,如果還是出現(xiàn)錯(cuò)誤提示。就作第6步。一直到?jīng)]有錯(cuò)誤為止。
最后C:\Qt4.1.2\plugins\sqldrivers下將會(huì)生成需要的libqsqlmysql.a和qsqlmysql.dll。
找了一個(gè)測(cè)試文件,通過。
#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();?


}?

摘要: 一直想做一個(gè) EJB3.0 結(jié)合 Struts 的例子,前天剛好從網(wǎng)上找到了一個(gè)相關(guān)的 Tutorial ,于是小試了一把,雖然只是完成了 Tutorial 上的一小點(diǎn)功能,但是感覺還是有必要寫下來(lái),免得以后還要再去看別人的Tutorial 。
開發(fā)環(huán)境:?? ??? Eclipse3.2 + WTP1.5 , JBoss 4.0.3SP1 , jboss-EJB-3.0_RC...
閱讀全文
SSH(Spring + Struts + Hibernate)小試 之三
前面通過PlugIn我們實(shí)現(xiàn)了Spring Context的加載,不過僅僅加載Context并沒有什么實(shí)際
意義,我們還需要修改配置,將Struts Action交給Spring容器進(jìn)行管理。下面將通過一個(gè)Regsit
實(shí)例加以說(shuō)明。
首先準(zhǔn)備好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按照原來(lái)Struts的方法去寫,我在RegistAction中加入了一個(gè)UserDAO對(duì)象
userDAO,這個(gè)對(duì)象由Spring注入。
<bean name="/regist" class="com.lzy.forum.action.RegistAction"
singleton="false">
<property name="userDAO">
<ref local="userDAO" />
</property>
</bean>
基本上SSH的架構(gòu)已經(jīng)完成,經(jīng)確認(rèn)后可以自己測(cè)試一下了。(完)
Spring和Struts結(jié)合有幾種方法,我選了最常用的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的配置文件,下面給出的是整個(gè)的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>
經(jīng)過這樣的配置之后,Hibernate事務(wù)交由Spring管理,sessionFactory從Spring容器獲得。下面通過其中的一個(gè)DAO實(shí)例來(lái)看看這樣做帶來(lái)的方便。
//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()得到一個(gè)HibernateTemplate實(shí)例,然后執(zhí)行CRUD操作,非常簡(jiǎn)單。需要注意的是,由于執(zhí)行一次CRUD操作后,Hibernate session關(guān)閉,如果有使用延遲加載策略的對(duì)象沒有加載,在后面的Web層很容易出現(xiàn)如下錯(cuò)誤:
failed to lazily initialize a collection of role
從網(wǎng)上搜到的解決方法是Open Session In View,
<filter>
???? <filter-name>hibernateFilter</filter-name>
???? <filter-class> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
???? </filter-class>
???? <!-- singleSession默認(rèn)為true,若設(shè)為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>
我試了試,還是有一些問題,所以后來(lái)還是放棄了這種方法,所有在Web層中需要的對(duì)象都必須在Business層中加載完成。如下面的代碼所示:
ArrayList list = (ArrayList) this.getHibernateTemplate().find(
????"from Board b left join fetch b.Articles where b.Id = ? ", new Object[] { id });
這樣Hibernate和Spring的結(jié)合也算完成了。其他的一些DAO類和實(shí)現(xiàn)代碼我沒有給出,但是大同小異,和Board的實(shí)現(xiàn)類似。
最后將是Struts 和Spring的結(jié)合,將在下一篇給出。(未完待續(xù))
之前對(duì)Spring Struts Hibernate都稍有了解,Spring的IOC給我留下了很深的印象,容器管理的對(duì)象生成
方法極大地簡(jiǎn)化了程序邏輯,Spring也提供了用于Web的Spring MVC 框架,由于我感覺其易用性還是不及
Struts,所以我還是選擇Struts作為前端WEB框架,Hibernate我一直沒有在Web應(yīng)用中試過,這次當(dāng)然不會(huì)
錯(cuò)過機(jī)會(huì)了。
開發(fā)環(huán)境的塔建我就不多說(shuō)了,具體可以參考我以前的幾篇日志。
在Eclipse中新建一個(gè)動(dòng)態(tài)Web工程,將Struts 、Spring、Hibernate需要的jar都添加到WEB-INF/lib目錄下,
將Struts標(biāo)簽所需的tld文件、struts-config.xml文件(可以由StrutsIDE生成)添加到WEB-INF下,另外在
此目錄下添加一個(gè)Spring的配置文件applicationContext.xml。
我參考的例子是夏昕的《深入淺出Hibernate》上的第6章,很好的一個(gè)論壇示例。
首先按照書上的ER模型,在數(shù)據(jù)庫(kù)(MySQL)中建立相應(yīng)的數(shù)據(jù)庫(kù)。
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來(lái)生成映射文件和實(shí)體類,然后對(duì)生成的類進(jìn)行修改(刪掉了生成的Base類),
實(shí)際上Hibernate Sychonizer生成的映射文件也有錯(cuò)誤,需要修改,我也是后來(lái)在使用中發(fā)現(xiàn)的。
//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是后來(lái)修改的,Hibernate Sychonizer生成的有錯(cuò),后面有幾處同樣的錯(cuò)誤】
???<one-to-many class="Article"/>
??</set>
??<set name="Boards" inverse="true" lazy="true">
???<key column="create_by"/>【這里的create_by是后來(lái)修改的】
???<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是后來(lái)修改的】
???<one-to-many class="Article"/>
??</set>
??<set name="ChildBoards" inverse="true"? lazy="true" order-by="id">
???<key column="parent_id"/>【這里的parent_id是后來(lái)修改的】
???<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是后來(lái)修改的】
???<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;
?}
?
}
接下來(lái)將會(huì)在web中加入Spring支持和為實(shí)體類提供DAO支持。(未完待續(xù))
環(huán)境:
(1)安裝Eclipse + CDT + MinGW
(2)安裝QT for Windows
(3)安裝QT plugin for Eclipse :org.eclipse.qt-1.0.2.zip,在Preference里設(shè)好相關(guān)路徑。
新建一個(gè) QT project,將hello。cpp復(fù)制到工程中:
#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,新建兩個(gè)Make Target:all,clean
Make all 后發(fā)現(xiàn)找不到libQtCored4.a等文件,在QT的lib目錄下找到相應(yīng)的libQtCore4.a,復(fù)制后重命名為libQtCored4.a,
其他庫(kù)文件類似,最后編譯通過,運(yùn)行后出現(xiàn)帶hello按鈕的窗口。
?
Eclipse + CDT + MinGW環(huán)境的搭建比較簡(jiǎn)單,由于機(jī)器內(nèi)存不夠大,我在preference里將C++的indexer都置為NO INDEXER。
安裝MinGW后可以看到,在Include和Lib目錄下有了與OpenGL相關(guān)的頭文件和靜態(tài)庫(kù)。為了使用GLUT,我將glut.h放到了相應(yīng)的
GL目錄下,看到Lib目錄下有l(wèi)ibglut.a庫(kù)文件,我沒有將glut。lib放進(jìn)去(后來(lái)發(fā)現(xiàn)libglut。a好像在windows不可用)。
新建一個(gè)Standtart Make C++ project,將原來(lái)可運(yùn)行的OpenGL程序復(fù)制過來(lái),寫好Makefile,結(jié)果編譯的時(shí)候還是出現(xiàn)錯(cuò)誤。
還好找到了這個(gè)非常有用的網(wǎng)頁(yè):http://www.mingw.org/MinGWiki/index.php/Glut
按照上面列出的錯(cuò)誤,我在每個(gè)#include<GL/glut.h>前都加上#define _STDCALL_SUPPORTED,然后又將glut32。lib、
opengl32.lib、glu32.lib都放到當(dāng)前的工程目錄下,用”glut32。lib opengl32.lib glu32.lib“ 代替原來(lái)的 ”-lglut -lopengl32 -lglu32",
最后終于編譯通過。
?
摘要: 在EJB 3.0 學(xué)習(xí)筆記——準(zhǔn)備工作中只是簡(jiǎn)單的搭好了EJB3.0開發(fā)的基本環(huán)境,之
后就可以開發(fā)最簡(jiǎn)單的Session Bean了,我感興趣的還是Entity Bean,所以接下來(lái)
我想先試驗(yàn)一下Entity Bean。?一、在JBoss中配置好Data Source我使用的是MySQL數(shù)據(jù)庫(kù),所以首先將MySQL的JDBC驅(qū)動(dòng)復(fù)制到j(luò)boss-4.0.3SP1\server\al...
閱讀全文
Java Script
調(diào)用
java
可以在網(wǎng)頁(yè)里使用
<script language=javascript>
?????? document.applet_name.method_name();
</script>
可以對(duì)
applet
進(jìn)行控制,也可以從
applet
返回值。
?
?
Java
調(diào)用
Java Script
需要導(dǎo)入
netscape.javascript.jsobject
這個(gè)類 (jre/lib/plugin.jar)
比如:
JSObject window=JSObject.getWindow(this);
JSObject window=(JSObject)window.getMember("document");
來(lái)獲取對(duì)當(dāng)前窗口的控制權(quán)。
?
當(dāng)點(diǎn)擊鏈接
MakeCall
時(shí),會(huì)觸發(fā)
Java Script
函數(shù)
?
function makeCall(s){
? window.document.ctiApplet.testJavascript(s);
? alert("call maked!");
?}
?
在這個(gè)
Java Script
函數(shù)中,
ctiApplet
是一個(gè)
Applet
,這樣完成了
java script
調(diào)用
Applet
。
以下是
ctiApplet
中的
testJavascript
函數(shù)和運(yùn)行結(jié)果,其中又調(diào)用了
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);
}
?
?
?
在開發(fā)EJB3.0 之前,首先應(yīng)該去下載它的一個(gè)實(shí)現(xiàn)和一個(gè)相應(yīng)的支持EJB3的服務(wù)器,我下載的是jboss-EJB-3.0_RC5-PFD和JBoss 4.0.3SP1 ,jboss-EJB-3.0_RC5-PFD里面有安裝說(shuō)明和一些不錯(cuò)的tutorial。
根據(jù)安裝說(shuō)明,JBoss 4.0.3SP1中的EJB3實(shí)現(xiàn)不是最新的,應(yīng)用下載的jboss-EJB-3.0_RC5-PFD中的一些包去替換。
將jboss-EJB-3.0_RC5-PFD中l(wèi)ib目錄下的
?(1)ejb3.deployer/
?(2)ejb3-clustered-sfsbcache-service.xml
?(3)ejb3-interceptors-aop.xml
?(4)jboss-aop-jdk50.deployer/
拷貝到j(luò)boss-4.0.3SP1/server/all/deploy目錄下
將jboss-EJB-3.0_RC5-PFD中l(wèi)ib目錄下的
?(5)jboss-remoting.jar
?(6)jboss-serialization.jar
?(7)jboss-j2ee.jar
拷貝到j(luò)boss-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 的運(yùn)行環(huán)境準(zhǔn)備好了,你可以用jboss-4.0.3SP1\bin\run -c all 測(cè)試JBoss是否能成功啟動(dòng)。
我用的IDE是Eclipse 3.2,JDK 1.5 ,為了方便在Eclipse中新建一個(gè)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中,現(xiàn)在環(huán)境基本上搭好了。
在FreeBSD 5.x中,kernel配置文件的設(shè)備名改為sound,不是FreeBSD 4.x中的pcm了,以后還有可能改為snd。
#cd /usr/src/sys/i386/conf/
#make LINT
可生成LINT文件,將kernel配置里的項(xiàng)全部列出了。
在kernel配置文件里加上
device sound
device snd_foo 或
device "snd_foo" <----注意這里foo表示不同的聲卡種類,可參考LINT文件。
如果不知道你的聲卡應(yīng)該用哪一個(gè),可以先用
#kldload snd_driver 將所有常用的聲卡驅(qū)動(dòng)裝載,然后用
#cat /dev/sndstat 察看是否有相應(yīng)的聲卡信息,如:
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就是對(duì)應(yīng)的應(yīng)該裝載的設(shè)備。
注意如果對(duì)應(yīng)的聲卡種類中有數(shù)字,就應(yīng)該加上引號(hào)。
這樣重新編譯內(nèi)核就可以了。當(dāng)然如果不編譯內(nèi)核,用load module的方式也可以。
那么我的問題是什么呢? 我用
#dmesg|grep pcm 能察看到聲卡信息。
用 #cat /dev/sndstat 也能看到正確的聲卡信息。
并且能夠播放CD,但是使用xmms等軟件播放mp3文件的時(shí)候,播放條根本不走。而后從dmesg可看到如下信息:
pcm0:play:0: play interrupt timeout, channel dead
經(jīng)過Google查詢,懷疑問題出在系統(tǒng)ICQ沖突上。最后,在啟動(dòng)FreeBSD 5.3時(shí),選擇了ACPI Disable,就能夠正確地用xmms播放了。
最后補(bǔ)充以下,我的機(jī)器安裝了兩塊網(wǎng)卡,一塊SCSI卡。使用的是版載聲卡。怎么解決在ACPI情況下使用還不清楚。但問題基本確定的確是ICQ資源的問題。
五一這幾天沒事閑的裝了FreeBSD,時(shí)間可沒少花,問題卻還是不少,也許對(duì)系統(tǒng)還不是太熟悉吧.
1.USB鼠標(biāo)的問題
第一次裝的時(shí)候,測(cè)試鼠標(biāo)的時(shí)候沒動(dòng)靜,不知當(dāng)時(shí)是不是鼠標(biāo)沒插好
只好用PS/2口了,后來(lái)編譯了一遍內(nèi)核,USB才能用.
然而最后一次裝的時(shí)候,USB口可以用,但是startx進(jìn)入KDE的時(shí)候總是失敗,找不到什么Pointer,將鼠標(biāo)插入
PS/2口后重啟,上述現(xiàn)象又沒了,感覺很是奇怪,進(jìn)入kde后將鼠標(biāo)插入U(xiǎn)SB口也正常.
2..xinitrc文件的問題
第一次裝的時(shí)候是按照書上裝的,當(dāng)時(shí)把xinitrc文件復(fù)制過來(lái)
cp /usr/X11R6/lib/X11/xinitrc/xinitrc /root/.xinitrc
3.中文字體和輸入法
首先安裝cvsup,更新ports,然后安裝kde-zh******,之后就可以看到kde的一些界面已經(jīng)中文化了,但是還是有亂碼,弄個(gè)中文字體過來(lái)就可以了
將windows中的simsun.ttc改名為simsun.ttf后復(fù)制到/usr/X11R6/lib/X11/fonts/TTF中,然后運(yùn)行命令
fc-cache -f -v就可以了
中文輸入法很簡(jiǎn)單.fcitx,不過以前裝的時(shí)候沒有更新ports時(shí)好象不行.
目前預(yù)留的 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
下面是目前預(yù)留的 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:
以前遇到JSP 處理MySQL數(shù)據(jù)庫(kù)時(shí)的中文問題時(shí),采取的是很笨的一種方法,直接用字符串編碼轉(zhuǎn)換函數(shù)進(jìn)行轉(zhuǎn)換,這次從網(wǎng)上搜了一下,找到了一個(gè)使用Filter的可行方法。在Tomcat 5.5+ MySQL4.0.16下通過。
filter類源碼是從網(wǎng)上找的,如下
/**
*
*/
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 文件中作如下設(shè)置:(我使用的是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>
最后,連接數(shù)據(jù)庫(kù)時(shí),使用下面的url:
jdbc:mysql://localhost:3306/數(shù)據(jù)庫(kù)名?useUnicode=true&characterEncoding=GBK
1.下載Spring相關(guān)的開發(fā)包
下載地址:http://sourceforge.net/project/showfiles.php?group_id=73357
有spring-framework-1.2.6-with-dependencies.zip,一個(gè)是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,將在這個(gè)XML文件中為一個(gè)HelloBean的實(shí)例的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.新建測(cè)試類: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.運(yùn)行測(cè)試類:
如果沒有出錯(cuò),輸出中將會(huì)看到“hello world”。
1.開發(fā)環(huán)境
與Eclipse下Struts的開發(fā)類似,安裝好Eclipse和Tomcat之后,還需要兩個(gè)插件:tomcat 插件和JSF插件(如果相關(guān)插件還沒有安裝),以下是相關(guān)下載地址:
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 插件的安裝和配置有問題請(qǐng)直接Google。
2.開始
入門嘛,我們就找一個(gè)最簡(jiǎn)單的Login就可以了
新建Tomcat project
加入JSF支持
新建一個(gè)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;
}
}
新建兩個(gè)JSP頁(yè)面,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.測(cè)試
在test工程中選擇tomcat project->Update context definition
然后運(yùn)行Tomcat
http://127.0.0.1:8080/jsfTest/login.jsf
1.開發(fā)環(huán)境
開發(fā)之前首先應(yīng)該準(zhǔn)備好開發(fā)環(huán)境,Eclipse 3.X是一個(gè)不錯(cuò)的Java IDE,有很多插件可以供我們選擇,服務(wù)器用Tomcat就行了。安裝好Eclipse和Tomcat之后,還需要兩個(gè)插件:tomcat 插件和Struts插件,以下是相關(guān)下載地址:
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
插件的安裝和配置有問題請(qǐng)直接Google。
2.開始
入門嘛,我們就找一個(gè)最簡(jiǎn)單的Login就可以了
新建Tomcat project,如下圖
加入struts支持
新建一個(gè)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;
}
}
新建一個(gè)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");
}
}
}
新建兩個(gè)JSP頁(yè)面,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.測(cè)試
在test工程中選擇tomcat project->Update context definition
然后運(yùn)行Tomcat
http://127.0.0.1:8080/test/login.jsp
這幾天在圖書館看到了一本書《Java SOAP編程指南》,出于對(duì)正興起的web service的好奇,借了回來(lái)。看了一下SOAP的介紹,沒太明白,只知道是Simple Object Access Protocol,和XML結(jié)合可以提供跨平臺(tái)的服務(wù)。
編程的人總有這么一個(gè)愛好,開始的時(shí)候總要拿一個(gè)HelloWorld似的例子試試,我也不例外。 要試當(dāng)然要有SOAP的運(yùn)行環(huán)境。按照書上的指示,裝好了Tomcat,下載了相關(guān)的包,將soap.jar ,mail.jar,activatio.jar,xercesImpl.jar 加入到了環(huán)境變量classpath中,將soap.war拷貝到了TOMCAT的webapps目錄下。
運(yùn)行SOAP的測(cè)試目錄:HTTP://127.0.0.1:8080/soap/發(fā)現(xiàn)soap已經(jīng)正常工作。 接著便是部署新的SOAP服務(wù)了,按照書上的源碼,寫好了測(cè)試用的部署類和客戶端類,編譯通過。在部署新的SOAP的web頁(yè)面下按照書上的步驟添好表單并部署完成。將測(cè)試所在目錄添加到classpath中。 重啟tomcat。 運(yùn)行剛才編譯好的客戶端類,結(jié)果NoClassDefError。
試了好幾遍,都是這樣,很是讓我郁悶啊。 看了另一本書《java web服務(wù)應(yīng)用開發(fā)詳解》終于找到了答案: 運(yùn)行客戶端測(cè)試程序時(shí),***Client.class是在Package test中的 運(yùn)行時(shí)退回到test的上級(jí)目錄,java test.***Client 即可。 我想遇到類似問題,還是對(duì)java的包不熟悉。
Eclipse,我想任何一個(gè)學(xué)習(xí)Java的人都會(huì)知道它,一個(gè)很不錯(cuò)的開發(fā)環(huán)境,不光能開發(fā)基于Java的各種程序,還能做C++開發(fā),比起JBuilder,我覺得Eclipse有過之而無(wú)不及,尤其它還是一個(gè)開源項(xiàng)目,很多東西都是JBuilder沒有的。
Eclipse 是一個(gè)基于插件的開發(fā)平臺(tái),很多功能都是通過插件來(lái)完成的。比如說(shuō)要做Java圖形界面開發(fā),如使用AWT和SWING的開發(fā),就需要下載相應(yīng)的插件,因此使用Eclipse時(shí)除了基本的Eclipse SDK還需要下載安裝相應(yīng)的插件。
下面是一些相關(guān)的下載地址:
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
安裝完JBuilder 9 Enterprise版后,看到介紹中說(shuō)可以支持J2ME的開發(fā),所以想試一下。
因?yàn)镴2ME需要另外的jdk支持,所以第一步就是安裝相應(yīng)的wireless toolkit jdk.
相應(yīng)的jdk可以從sun的官方網(wǎng)站上下載,安裝過程也非常簡(jiǎn)單
這里不再詳敘。
安裝完后,將新的jdk添加到JBuilder的配置中,Tools->Configure JDKs
之后,新建工程,選擇剛才的jdk。
打開Project->Project Properties,在run 選項(xiàng)卡中點(diǎn)New
在彈出框中選擇run, type改為MIDlet(原來(lái)為Application)。
之后就可以新建MIDlet了。
//留言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;
}
}
//// 用于數(shù)據(jù)庫(kù)操作的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;
}
}
///以下是網(wǎng)頁(yè)源碼
<!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("請(qǐng)輸入頁(yè)數(shù)");
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">收藏本頁(yè)</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" >首頁(yè)</a></td>
<td width="12%" align="center" bgcolor="#CCFFFF"><a href="loginForm.htm" >登陸</a></td>
<td width="12%" align="center" bgcolor="#CCFFFF"> </td>
<td width="12%" align="center" bgcolor="#CCFFFF"> </td>
<td width="12%" align="center" bgcolor="#CCFFFF" > </td>
<td width="12%" align="center" bgcolor="#CCFFFF"> </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">注冊(cè)</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);%> 頁(yè),現(xiàn)在是第<%out.print(currentPage);%> 頁(yè)</td>
<td width="64%">
<a href="memoDisplay.jsp?page=<%=currentPage-1%>" >上一頁(yè) </a>
<a href="memoDisplay.jsp?page=<%=currentPage+1%>" >下一頁(yè) </a>
<a href="memoDisplay.jsp?page=1" >首頁(yè) </a>
<a href="memoDisplay.jsp?page=<%=totalPages%>" >尾頁(yè) </a>
<input type="submit" name="Submit" value="G0">
<input name="page" type="text" size="10">
頁(yè)</td>
</tr>
</form></table>
<%
for(int i=0;i<countPerPage&¤tStart-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"> </td>
</tr>
</table></td>
</tr>
</table>
</center></body>
</html>
Step1:
查找驅(qū)動(dòng)程序 MySQL目前提供的java驅(qū)動(dòng)程序?yàn)镃onnection/J,可以從MySQL官方網(wǎng)站下載,并找到mysql-connector-java-3.0.15-ga-bin.jar文件,此驅(qū)動(dòng)程序?yàn)榧僯ava驅(qū)動(dòng)程序,不需做其他配置。
Step2:
動(dòng)態(tài)指定classpath 如果需要執(zhí)行時(shí)動(dòng)態(tài)指定classpath,就在執(zhí)行時(shí)采用-cp方式。否則將上面的.jar文件加入到classpath環(huán)境變量中。
Step3:
加載驅(qū)動(dòng)程序
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:
設(shè)置連接的url jdbc:mysql://localhost/databasename[?pa=va][&pa=va]
以前有過在linux下裝Apache+PHP+MySQL的經(jīng)驗(yàn),這幾天裝了FreeBSD,我想在下面也裝個(gè)數(shù)據(jù)庫(kù)玩玩,當(dāng)然首選MySQL了,這個(gè)簡(jiǎn)單呀.
1.MySQL
找到了/usr/ports/databases/mysql50-server
cd /usr/ports/databases/mysql50-server
make install clean
之后的數(shù)據(jù)庫(kù)并沒有生成
需要添加用戶mysql:mysql
運(yùn)行mysql_install_db
就會(huì)發(fā)現(xiàn)在/var/db下生成了mysql目錄,里面就是mysql的數(shù)據(jù)庫(kù)文件了
chown -R mysql:mysql /var/db/mysql
在rc.conf中加入mysql_enable="YES"
/usr/local/etc/rc.d/mysql-server.sh -start
如果沒有錯(cuò)誤的話mysql就運(yùn)行了
裝了這個(gè)當(dāng)然掛個(gè)服務(wù)器測(cè)試測(cè)試了
2.Apache
cd /usr/ports/www/apache20/
以前在linux下裝的時(shí)候有個(gè)參數(shù)--enable-so
我給加到了Makefile里,不知道有沒有必要,反正后來(lái)也裝好了
make install clean
安裝成功
修改一下配置文件httpd.conf
在rc.conf中加入apache2_enable="YES"
/usr/local/etc/rc.d/apache2.sh start
啟動(dòng)成功的話也就可以了
3.PHP
cd /usr/ports/www/mod_php5
make install clean
安裝的時(shí)候選中那個(gè)with apache什么的就可以了
安裝后將httpd.conf中的loadmodule 最后一個(gè)剛加進(jìn)去的php的#去掉
Addtype 行加入.php .phps
寫一個(gè)phpinfo()測(cè)試一下就可以了
4.PHP+MySQL
裝mod_php5的時(shí)候沒有加入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/
測(cè)試通過
6.Tomcat+MySQL
到mysql的官方網(wǎng)站下一個(gè)聯(lián)接器,將相應(yīng)的jar文件放到
tomcat相應(yīng)目錄下
7.Apache + Tomcat
我剛開始的時(shí)候裝了mod_jk2-apache2
結(jié)果沒有成功,又裝mod_jk-apache2,也沒有成功啊
后來(lái)想起在windows下成功過,去看了看,發(fā)現(xiàn)用的是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創(chuàng)建shm.file
chown -R www:www var/log/shm.file
之后重啟Apache和Tomcat
測(cè)試:http://127.0.0.1/index.jsp
發(fā)現(xiàn)成功了
呵呵,大功告成
Red Hat 9:Linux下安裝mplayer播放器 |
|
在Linux RH9下安裝mplayer很多次了,以前都是以失敗而告終,前兩天終于裝成功了,為自己感到慶幸。大家以后安裝的時(shí)候可以作為一個(gè)參考(有些地方我也是參考別人的)。
mplayer是linux下播放速度最快(正確安裝了顯卡驅(qū)動(dòng)),支持媒體格式最多的播放器之一 ,它幾乎能播放所有的win媒體文件!下面介紹它的安裝方法:
安裝大前提: 要編譯這個(gè)軟件,確認(rèn)你系統(tǒng)安裝了相應(yīng)的XFree86-devel,還有如果你要編譯gui操作界面 (./configure --enable-gui),還請(qǐng)確認(rèn)你的系統(tǒng)有l(wèi)ibpng,libpng-devel,gtk和 gtk-devel(要求版本大于1.2)這四個(gè)軟件,可以在www.rpmfind.net找到相應(yīng)的rpm包 (這些包通過安裝Gnome桌面可以獲得) 1、在下載mplayer的最新版本及安裝所需軟件包的集合包
2、升級(jí)gcc: (必要,推薦gcc版本為2.9.5和3.2.x) 檢查你的gcc版本,運(yùn)行g(shù)cc -v看輸出是多少,如果是3.0以下的話,則建議安裝gcc3.0以 上(根據(jù)mplayer的官方說(shuō)明,3.0以下的gcc可以用./configre --disable-gcc-checking 參數(shù)編譯,但可能不穩(wěn)定),安裝gcc3的方法是:進(jìn)入gcc3目錄,運(yùn)行rpm -ivh *.rpm --nodeps,全部百分百安裝后,開一個(gè)終端窗口,運(yùn)行mv /usr/bin/gcc /usr/bin/gcc2 和mv /usr/bin/gcc3 /usr/bin/gcc,再運(yùn)行g(shù)cc -v,看輸出是否為3.0.2,如果是,則ok ,不是,則檢查安裝步驟。
3、編譯安裝mplayer: tar vxf MPlayer-****.tar,cd MPlayer-****,./configure (如果你想 要gui的操作界面,則換用這個(gè)命令./configrue --enable-gui,但似乎這個(gè)版本的gui編 譯有錯(cuò),我和linuxCN都無(wú)法成功,pre4版本則沒問題),make,make install,都成功運(yùn)行一下mplayer(這是為了讓它在家目錄下建立.mplayer這個(gè)配置目錄 (.mplayer為隱藏目錄,用ls -a指令可以看見,cd ~/.mplayer指令可以進(jìn)入),好進(jìn)行下一 步操作)
./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 重要參數(shù)說(shuō)明: --prefix= 安裝路徑為/usr/local --enable-gui 使用圖形界面,mplayer有命令行和圖形界面兩種運(yùn)行方式 --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解碼器搜索路徑
現(xiàn)在使用 make 自動(dòng)編譯軟件,可以去吃飯,回來(lái)再看
make install //安裝
運(yùn)行mplayer ./mplayer
4、拷貝配置文件:(注意:下面這個(gè)etc目錄是上一步中解壓出來(lái)的MPlayer-***目 錄下的,非/etc) cp etc/codecs.conf ~/.mplayer cp etc/example.conf ~/.mplayer/config
5、安裝font和skin:(如果你選擇了./configure --enable-gui那才需要skin,否則skin 不用安裝) 進(jìn)入自己的home目錄,顯示隱藏文件,進(jìn)入.mplayer文件夾,創(chuàng)2個(gè)建文件夾:font和 Skin。
下載font文件,(mplayer官方網(wǎng)站上有)拷入到font內(nèi)拷貝simsun.ttf到~/.mplayer目錄中 拷貝Blue皮膚目錄到/usr/local/share/mplayer/Skins目錄中
6、運(yùn)行方式 兩種:(1)mplayer /路徑/要播放的媒體文件名;(2)gmplayer(只有用./configure --enable-gui編譯的這個(gè)命令才有效)
現(xiàn)在可以運(yùn)行mplayer和gmplayer了。但是gmplayer字幕出現(xiàn)問題,提示找不到
字幕字體文件。按照提示拷貝simsun.ttf(其他字體文件也可以)到~/.mplayer目錄中(改文件名)。
7、關(guān)于~/.mplayer/config文件的一些配置說(shuō)明 vo=xv(選擇默認(rèn)的播放模式,xv模式是支持顯卡硬加速功能的模式,對(duì)cpu的占用很小, 推薦;更多的顯示模式可以用命令mplayer -vo help看,其中的vesa模式可以在不啟動(dòng) xwin界面時(shí)播放,有點(diǎn)象當(dāng)年DOS下的金山影霸) ao=oss(選擇聲音的播放模式,oss是兼容性最好的播放模式,推薦;你也可以試試sdl模 式) fs=yes(全屏模式,yes的話默認(rèn)以全屏播放,no或前面加#號(hào)注釋掉這行的話則默認(rèn)是1 :1播放模式) zoom=yes(即時(shí)改變電影畫面大小,yes的話則可以用鼠標(biāo)隨意將播放畫面拉大拉小,no 的話不能) gui = yes(默認(rèn)是圖形化操作界面,這需要你先前用./configure --enable-gui來(lái)編譯 ,否則的話就算yes也沒有g(shù)ui操作界面) skin = default(設(shè)置默認(rèn)的skin,將等號(hào)右邊的值換成skin所放目錄就可以設(shè)置想要的 skin為默認(rèn)了,這個(gè)參數(shù)在用gui操作界面才有效) cache = 8192(默認(rèn)的播放緩存大小,如果機(jī)器內(nèi)存夠大,則將它加大一點(diǎn),如果不是很 大,譬如128以下,還是用默認(rèn)的算了) framedrop = yes(允許跳幀,如果你的機(jī)器CPU速度非常非常慢的話請(qǐng)將這個(gè)yes,默認(rèn) 是no或前面加#號(hào)將這行禁止;對(duì)于366MHZ以上的機(jī)器,建議都設(shè)成no或前面加#號(hào)) 其他設(shè)置用默認(rèn)就行 。
|
******************************************************************************
先安裝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
現(xiàn)在您已經(jīng)將 Apache 2.0.NN 安裝在 /usr/local/apache。本安裝支持可裝載模塊
和標(biāo)準(zhǔn)的 MPM prefork。之后,可以使用如下命令啟動(dòng) Apache 服務(wù)器:
/usr/local/apache2/bin/apachectl start
如果成功,您可以停止 Apache 服務(wù)器并繼續(xù)安裝 PHP:
/usr/local/apache2/bin/apachectl stop.
9. cd ../php4-NN
10. 現(xiàn)在我們需要配置 PHP。在這里您可以用各種各樣的參數(shù)來(lái)自定義PHP,例如啟動(dòng)哪
些擴(kuò)展功能包的支持等。用 ./configure --help 命令可以列出當(dāng)前可用的所有參
數(shù)。在我們的例子中,我們將給出一個(gè)在有 MySQL 支持的 Apache 2 上進(jìn)行配置的
范例。您本地的 apxs 的路徑可能會(huì)不同,事實(shí)上,在您的系統(tǒng)中,它可能被命名為
apxs2。
./configure --with-apxs2=/usr/local/apache2/bin/apxs
11. make
12. make install
如果您決定在安裝后改變配置選項(xiàng),您只需重復(fù)最后的三步,然后需要重新啟動(dòng)
Apache 使新模塊生效。無(wú)需重新編譯。
請(qǐng)注意,除非明確有提示,否則 'make install' 命令將安裝 PEAR、各種 PHP 工具
諸如 phpize,安裝 PHP CLI 等等。
13. 配置 php.ini
cp php.ini-dist /usr/local/lib/php.ini
您可以編輯 php.ini 文件以修改 PHP 的選項(xiàng)。如果您想要把此文件放到另外的位置,
您需要在步驟 10 添加 --with-config-file-path=/path 選項(xiàng)。
如果您選擇 php.ini -recommended,請(qǐng)務(wù)必閱讀其中的變更的列表,它們將影響
PHP 的執(zhí)行。
14. 編輯 httpd.conf 文件以調(diào)用 PHP 模塊。LoadMolude 表達(dá)式右邊的路徑必須指向您
系統(tǒng)中的 PHP。以上的 make install 命令可能已經(jīng)幫您完成了這些,但務(wù)必要檢查。
對(duì)于 PHP 4:
LoadModule php4_module modules/libphp4.so
對(duì)于 PHP 5:
LoadModule php5_module modules/libphp5.so
15. 告知 Apache 將特定的擴(kuò)展名解析成 PHP,例如,我們讓 Apache 將擴(kuò)展名 .php
解析成 PHP。您可以將任何擴(kuò)展名指定為 PHP,只需添加它們,每一個(gè)用空格分隔。
例如,我們要添加 .phtml:
AddType application/x-httpd-php .php .phtml
通常,我們還將 .phps 擴(kuò)展名設(shè)置成顯示高亮的 PHP 源文件,可以這樣來(lái)完成:
AddType application/x-httpd-php-source .phps
16. 啟動(dòng)您的 Apache 服務(wù)器:
/usr/local/apache2/bin/apachectl start
按照上面的步驟您便可以使 Apache 2.0 將 PHP 作為 SAPI 模塊了。當(dāng)然 Apache 和
PHP 都還有很多配置選項(xiàng),您可以在相應(yīng)的源代碼目錄中使用 ./configure --help 獲得
更多信息。假如您要編譯一個(gè)多線程版本的 Apache 2.0,您必須覆蓋標(biāo)準(zhǔn)的
MPM-Module
prefork,或者 worker 或者 perchild。要這樣,您需要在上面的第 6 步使用
--with-mpm=worker 或者 --with-mpm=perchild 選項(xiàng)。之前您需要了解您正在做什么。
更
多信息請(qǐng)參考 Apache 文檔中關(guān)于 MPM-Modules 的部分。
linux下編寫OpenGL程序的一些準(zhǔn)備工作 |
|
需要用到的軟件包有兩個(gè),glut 和tmake,分別可以從以下兩個(gè)網(wǎng)址下載: http://www.opengl.org/resources/libraries/glut/glut-3.7.tar.gz ftp://ftp.trolltech.com/freebies/tmake/tmake-1.8.tar.gz
下載后的文件假設(shè)都放在/usr/src中
首先是安裝glut庫(kù),以下是從www.linux.com找到的編譯glut庫(kù)的手冊(cè)。
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如果運(yùn)行成功的話,說(shuō)明glut已經(jīng)可以用了,這時(shí)可以將include/GL下的glut等頭文件復(fù)制到/usr/include中去。
上面的幾步中,下載的glut包放在/usr/src目錄下,如果放在其他目錄下,將/usr/src改為相應(yīng)的目錄即可。 此外應(yīng)該注意的是兩個(gè)Makefile文件的修改 改 · OPENGL = $(TOP)/../lib/libMesaGL.so GLU = $(TOP)/../lib/libMesaGLU.so 為 OPENGL = -lGL GLU = -lGLU 因?yàn)樗付ǖ哪夸浿袥]有l(wèi)ibMesaGL.so和libMesaGLU.so。
之后是tmake的配置,后面我們可以用它來(lái)生成pro工程文件和makefile文件。
先將下載的tmake解壓縮,tar -zxvf tmake-1.8.tar.gz 得到tmake-1.8目錄,之后設(shè)置兩個(gè)環(huán)境變量:PATH和TMAKEPATH PATH=$PATH:/usr/src/tmake-1.8/bin export PATH TMAKEPATH=/usr/src/tmake-1.8/lib/linux-g++ export TMAKEPATH
新建一個(gè)測(cè)試目錄test,將glut-3.7目錄下的progs/redbook目錄下的hello.c復(fù)制到test目錄中
之后生成一個(gè)pro文件:progen -o hello.pro
然后生成makefile文件:tmake hello.pro -o Makefile
編輯生成的Makefile文件,在加載動(dòng)態(tài)連接庫(kù)的行里面加入 -lglut -lXi -lXmu
保存,make。
./hello 可以看到運(yùn)行結(jié)果就可以了。 |
|
|
五一期間裝了個(gè)FreeBSD,5.3 release,KDE桌面,感覺還是不錯(cuò)
前些天在Redhat Linux弄過OpenGL的開發(fā)環(huán)境,那時(shí)是自己編譯的glut庫(kù),然后用tmake編寫makefile,感覺很方便。
五一期間裝了個(gè)FreeBSD,5.3 release,KDE桌面,感覺還是不錯(cuò)的,用多了感覺圖形界面都快趕上WindowsXP了。
還是入正題吧。我想試試glut,pkg_info|grep glut
發(fā)現(xiàn)有個(gè)libglut.6...的,是支持OpenGL的,不知道是不是我想要的glut.
查找libglut.so,發(fā)現(xiàn)在/usr/X11R6/lib里面了,版本3,對(duì)頭。
把在linux里用過的tmake,和opengl redbook源碼拷了過來(lái),設(shè)置好tmake相關(guān)的環(huán)境變量
當(dāng)然最重要的是改相應(yīng)的tmake.conf文件了,將glut相關(guān)的庫(kù)加進(jìn)去
新建目錄test,將hello.c拷進(jìn)去,
progen -o hello.pro
tmake hello.pro "CONFIG+=opengl" -o Makefile
可以先檢查一下生成的Makefile,我沒有發(fā)現(xiàn)問題
make,成功,生成可執(zhí)行的hello
./hello出現(xiàn)一新窗口,本來(lái)應(yīng)該高興的,卻有點(diǎn)不對(duì)勁,窗口上什么也沒話
而且是白色背景,應(yīng)該是黑色背景然后畫一個(gè)白色的正方形。
google了好久,終于發(fā)現(xiàn)有人跟我遇到過同樣的問題
解決的方法很簡(jiǎn)單 link的時(shí)候加上 -pthread選項(xiàng),我先改了一下生成的Makefile,加上了-pthread
make,也通過了,看來(lái)問題有可能解決了
./hello 終于正確的結(jié)果出現(xiàn)了
使用tmake生成Qt程序的makefile文件
使用tmake生成Qt程序的makefile文件真的是很簡(jiǎn)單,本來(lái)tmake就是發(fā)布Qt那個(gè)公司的產(chǎn)品啊. 自己編寫.h和.cpp文件時(shí),tmake的用法可以在安裝文檔里找到. 使用Qt Designer時(shí)呢,生成的是.ui文件,這時(shí)也可以用tmake的: 假設(shè)生成的.ui文件名為mainform.ui,自己寫一個(gè)簡(jiǎn)單的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();
}
接下來(lái)就可以使用tmake了
progen -o main.pro
tmake main.pro -o Makefile
make
./main 呵呵,可以了