2005年12月14日
#
- 基本包的安装
sudo apt-get install tetex-base tetex-bin tetex-extra
- CJK包安装
sudo apt-get install latex-cjk-chinese
- 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
摘要: 很久没有看Java相关的东西了,这几天才发现Struts2 已经发布了,以前就听说Struts2就是以前的Webwork2,只是作了少许的改动而已,我以前也没看过Webwork,所以赶紧下来试了一把。Struts2的地址:http://struts.apache.org/2.x在Eclipse中新建了一个Tomcat工程(如果用WTP插件的话Dynamic Web工程)struts2Test,以下...
阅读全文
前几天按照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/
前天刚装了个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();
}
摘要: 一直想做一个 EJB3.0 结合 Struts 的例子,前天刚好从网上找到了一个相关的 Tutorial ,于是小试了一把,虽然只是完成了 Tutorial 上的一小点功能,但是感觉还是有必要写下来,免得以后还要再去看别人的Tutorial 。
开发环境: Eclipse3.2 + WTP1.5 , JBoss 4.0.3SP1 , jboss-EJB-3.0_RC...
阅读全文
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的架构已经完成,经确认后可以自己测试一下了。(完)
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" "http://www.springframework.org/dtd/spring-beans.dtd">
<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的结合,将在下一篇给出。(未完待续)
之前对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支持。(未完待续)
环境:
(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按钮的窗口。
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",
最后终于编译通过。
摘要: 在EJB 3.0 学习笔记——准备工作中只是简单的搭好了EJB3.0开发的基本环境,之
后就可以开发最简单的Session Bean了,我感兴趣的还是Entity Bean,所以接下来
我想先试验一下Entity Bean。 一、在JBoss中配置好Data Source我使用的是MySQL数据库,所以首先将MySQL的JDBC驱动复制到jboss-4.0.3SP1\server\al...
阅读全文
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);
}
在开发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中,现在环境基本上搭好了。
在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资源的问题。
五一这几天没事闲的装了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时好象不行.
目前预留的 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:
以前遇到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
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" "http://www.springframework.org/dtd/spring-beans.dtd">
<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”。