| Perfil de Yun无尽的探索FotosBlogListas | Ayuda |
|
26 noviembre MySQL Reference: 12.4.3. Statements That Cause an Implicit CommitEach of the following statements (and any synonyms for them) implicitly end a transaction, as if you had done a
Transactions cannot be nested. This is a consequence of the implicit Statements that cause an implicit commit cannot be used in an XA transaction while the transaction is in an 19 junio jQuery form提交时中文乱码 [转]关键字: ajax post 中文 乱码 在使用jsp开始时,一不小心就会出现中文乱码的情况。通常可以使用如下方法解决:
jQuery.each( a, function(){
s.push( encodeURIComponent(this.name) + "=" + encodeURIComponent( this.value ) );
});所以传给servlet的就是utf-8编码了,那么我们在过滤器中就必须使用utf-8进行转码。 对其中的过滤器做了下修正,在IE下和chrome下,request.getContentType()的值为"application/x-www-form-urlencoded",但是在firefox下,这个值为"application/x-www-form-urlencoded; charset=UTF-8",不是很明白ff为什么会是这个值。 filter代码如下:
package com.ajax.demo.action;
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;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class AjaxPostFilter implements Filter {
private static final String IE_CONTENT_TYPE = "application/x-www-form-urlencoded";
private static final String FF_AJAX_CONTENT_TYPE = "application/x-www-form-urlencoded; charset=UTF-8";
private static final String XMLHTTP_REQUEST = "XMLHttpRequest";
private static final String AJAX_CHARACTER_ENCODING_UTF8 = "UTF-8";
public void destroy() {
// TODO Auto-generated method stub
}
public void doFilter(ServletRequest servletRequest,
ServletResponse servletResponse, FilterChain filterChain)
throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) servletRequest;
HttpServletResponse response = (HttpServletResponse) servletResponse;
String requestedWith = request.getHeader("x-requested-with");
String type = request.getContentType();
if (XMLHTTP_REQUEST.equals(requestedWith)&& (FF_AJAX_CONTENT_TYPE.equals(type)
||IE_CONTENT_TYPE.equals(type))) {
request.setCharacterEncoding(AJAX_CHARACTER_ENCODING_UTF8);
response.setCharacterEncoding(AJAX_CHARACTER_ENCODING_UTF8);
// request.getParameterMap();
}
filterChain.doFilter(request, response);
}
public void init(FilterConfig arg0) throws ServletException {
// TODO Auto-generated method stub
}
}
web.xml配置,我用的是struts
<filter> <filter-name>ajaxEncodeFilter</filter-name> <filter-class>com.ajax.demo.action.AjaxPostFilter</filter-class> </filter> <filter-mapping> <filter-name>ajaxEncodeFilter</filter-name> <url-pattern>*.do</url-pattern> </filter-mapping> <filter-mapping> <filter-name>ajaxEncodeFilter</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping> 这个filter应该在你的EncodeFilter之后,RoyMax说要在之前,我试了下是不行的。 经过这样设置之后,jsp使用gbk采用ajax提交就不会存在中文乱码了。 在使用chrome进行测试时,还发现chrome的一个奇怪问题,对于返回的结果,使用jquery.ajax处理
success:function showResponse(responseText, statusText) {
//这里name为input text id,如果"aa"在前,那么name的值会改为aa+返回的结果
$('#name').val("aa"+responseText);
//如果改成$('#name').val(responseText+"aa"),那么name的值仍然是//responseText,“aa”没有加到后面去,不知道是什么原因参考:http://jasin2008.javaeye.com/blog/312854 15 febrero 又见情人节二月的北京,春寒料峭。 清晨,还听见屋外呼呼地吹着大风。我和老婆伸着腰,抖擞精神,起床来。岳母张老师已经准备好了丰盛的早餐:咖喱排骨,凉拌紫白菜丝,凉拌榨菜丝,还有煮元宵。我和老婆都来不及洗漱就被喊上桌,先吃饭了。 感谢岳母准备好这么丰富营养的早餐,我们吃得饱饱的。然后洗漱完毕,收拾好行李,动身从昌平往城区赶了。还在车上,老婆就和我商量今天日子怎么安排? 今天可不是一般的日子,是情人节,认识老婆以来的过的第二个情人节。 早早的日子里,老婆就咕噜着要礼物,说如果没有礼物,就要把我啃成胡萝卜。这是可爱的、应该的事情啊,但买礼物也是件头疼的事情。记得去年情人节,也是在仓促之间,给当时的还是女朋友身份的老婆,买了一盒德芙巧克力,老婆珍视地放在床头,放了许久才开封逐一地吃掉。 又见情人节。怎么过?礼物是什么?老婆告诉我,给我的礼物她已经准备好了。我给老婆礼物了?还是个秘密。我只是坦言告诉老婆,给她的礼物需要她自己亲自去挑选。于是建议我们先去看电影,然后五道口去选礼物。 时光如沙漏中的沙一点点流逝,早晨还在昌平,到达知春里的时候已经是正午时分了。告诉妈妈我们不吃午饭了,径直乘车386去中关村,然后走路去美嘉电影城。在中关村大街上,随处可见一对对的情侣手牵着手,也时不时的看到街头花贩向路上的情侣兜售玫瑰。来到电影城,里面人头攒动,来看来电影的情侣很多。在三楼售票厅,买票的人已经排成一条长龙一直排到楼梯间。和老婆商量,决定不看电影了,回家去看下载的《马达加斯加2》。在此之前,还是去五道口,给老婆挑选礼物。 乘车731来到五道口,下了车,我拉着老婆来到宝岛眼镜店,这才告诉老婆,我要为她挑选一副太阳镜作为情人节礼物。老婆欣喜不已。总算我这番心思没有白费,还好没有被老婆啃成胡萝卜。店里的太阳镜样式倒是不少,老婆初初地挑来选去的,没有特别满意的。我们又出去逛了逛其它的三家眼镜店,都没挑到合适的,最后还是回到宝岛眼镜店,挑中了一款粉红色大眼镜的太阳镜。另外宝岛眼镜做优惠买一赠一的活动,如是还挑了另一副墨绿色的运动型太阳镜。老婆兴奋不已,回来的路上都戴着粉红色太阳镜。后来,我还给老婆买了一束三朵的含有一朵蓝色妖姬的玫瑰花。这个情人节总算是有个好的交代了。 老婆在路上说,她希望天天都是情人节。是啊老婆,我也希望天天都是情人节,这样我们能够天天这样愉快的逛街开心地购物。 14 noviembre Linux下修改网卡IP和网关修改ifcfg-eth0文件内容: [root@yourmachine ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 修改resolv.conf: [root@yourmachine ~]# vi /etc/resolv.conf nameserver 10.130.1.1 重新启动网络配置 12 septiembre Linux下安装Apache httpd + Subversion服务配置先决条件为了让你的版本库使用HTTP网络,你基本上需要两个包里的四个部分。你需要Apache httpd2.0和包括的mod_dav DAV模块,Subversion和与之一同分发的mod_dav_svn文件系统提供者模块,如果你有了这些组件,网络化你的版本库将非常简单,如:
你可以通过从源代码编译httpd和Subversion来完成前两个项目,也可以通过你的系统上的已经编译好的二进制包来安装。最新的使用Apache HTTP的Subversion的编译方法和Apache的配置方式可以看Subversion源代码树根目录的 基本的 Apache 配置一旦你安装了必须的组件,剩下的工作就是在 LoadModule dav_svn_module modules/mod_dav_svn.so 注意,如果mod_dav是作为共享对象编译(而不是静态链接到httpd程序),你需要为它使用 LoadModule dav_module modules/mod_dav.so LoadModule dav_svn_module modules/mod_dav_svn.so 基本HTTP认证最简单的客户端认证方式是通过HTTP基本认证机制,简单的使用用户名和密码来验证一个用户所自称的身份,Apache提供了一个htpasswd工具来管理可接受的用户名和密码,这些就是你希望赋予Subversion特别权限的用户,让我们给Sally和Harry赋予提交权限,首先,我们需要添加他们到密码文件。 $ ### First time: use -c to create the file $ ### Use -m to use MD5 encryption of the password, which is more secure $ htpasswd -cm /etc/svn-auth-file harry New password: ***** Re-type new password: ***** Adding password for user harry $ htpasswd -m /etc/svn-auth-file sally New password: ******* Re-type new password: ******* Adding password for user sally $ 下一步,你需要在 添加完这三个指示,你的 <Location /svn> DAV svn SVNParentPath /usr/local/svn AuthType Basic AuthName "Subversion repository" AuthUserFile /etc/svn-auth-file </Location> 这个 <Location /svn> DAV svn SVNParentPath /usr/local/svn AuthType Basic AuthName "Subversion repository" AuthUserFile /etc/svn-auth-file Require valid-user </Location> 授权选项此刻,你已经配置了认证,但是没有配置授权,Apache可以要求用户认证并且确定身份,但是并没有说明这个身份的怎样允许和限制,这个部分描述了两种控制访问版本库的策略。 整体访问控制最简单的访问控制形式是授权特定用户为只读版本库访问或者是读/写访问版本库。 你可以通过在 <Location /svn> DAV svn SVNParentPath /usr/local/svn # how to authenticate a user AuthType Basic AuthName "Subversion repository" AuthUserFile /path/to/users/file # only authenticated users may access the repository Require valid-user </Location> 有时候,你不需要这样严密,举个例子,Subversion自己在http://svn.collab.net/repos/svn的源代码允许全世界的人执行版本库的只读操作(例如检出我们的工作拷贝和使用浏览器浏览版本库),但是限定只有认证用户可以执行写操作。为了执行特定的限制,你可以使用 在 <Location /svn>
DAV svn
SVNParentPath /usr/local/svn
# how to authenticate a user
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /path/to/users/file
# For any operations other than these, require an authenticated user.
<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
</LimitExcept>
</Location>
这里只是一些简单的例子,想看关于Apache访问控制 每目录访问控制也可以使用Apache的httpd模块mod_authz_svn更加细致的设置访问权限,这个模块收集客户端传递过来的不同的晦涩的URL信息,询问mod_dav_svn来解码,然后根据在配置文件定义的访问政策来裁决请求。 如果你从源代码创建Subversion,mod_authz_svn会自动附加到mod_dav_svn,许多二进制分发版本也会自动安装,为了验证它是安装正确,确定它是在 LoadModule dav_module modules/mod_dav.so LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so 为了激活这个模块,你需要配置你的 Apache非常的灵活,你可以从三种模式里选择一种来配置你的区块,作为开始,你选择一种基本的配置模式。(下面的例子非常简单;见Apache自己的文档中的认证和授权选项来查看更多的细节。) 最简单的区块是允许任何人可以访问,在这个场景里,Apache决不会发送认证请求,所有的用户作为“匿名”对待。 例 6.1. 匿名访问的配置实例。 <Location /repos>
DAV svn
SVNParentPath /usr/local/svn
# our access control policy
AuthzSVNAccessFile /path/to/access/file
</Location>
在另一个极端,你可以配置为拒绝所有人的认证,所有客户端必须提供证明自己身份的证书,你通过 例 6.2. 一个认证访问的配置实例。 <Location /repos> DAV svn SVNParentPath /usr/local/svn # our access control policy AuthzSVNAccessFile /path/to/access/file # only authenticated users may access the repository Require valid-user # how to authenticate a user AuthType Basic AuthName "Subversion repository" AuthUserFile /path/to/users/file </Location> Apache和svnserve都可以给用户赋予(或拒绝)访问许可,通常是对整个版本库:一个用户可以读版本库(或不),而且他可以写版本库(或不)。如果可能,也可以定义细粒度的访问规则。一组用户可以有版本库的一个目录的读写权限,但是没有其它的;另一个目录可以是只对一少部分用户可读。 两种服务器都使用同样的文件格式描述路径为基础的规则,如果是Apache,需要加载mod_authz_svn模块,然后添加 当你的服务器知道去查找规则文件时,就是需要定义规则的时候了。 访问文件的语法与svnserve.conf和运行中配置文件非常相似,以( 具体一点:这个小节的名称是 [calc:/branches/calc/bug-142] harry = rw sally = r 在第一个例子里,用户 当然,访问控制是父目录传递给子目录的,这意味着我们可以为Sally指定一个子目录的不同访问策略: [calc:/branches/calc/bug-142] harry = rw sally = r # give sally write access only to the 'testing' subdir [calc:/branches/calc/bug-142/testing] sally = rw 现在Sally可以读取分支的 也可以通过继承规则明确的的拒绝某人的访问,只需要设置用户名参数为空: [calc:/branches/calc/bug-142] harry = rw sally = r [calc:/branches/calc/bug-142/secret] harry = 在这个例子里,Harry对 需要记住的是最详细的的路径会被匹配,服务器首先找到匹配自己的目录,然后父目录,然后父目录的父目录,就这样继续下去,更具体的路径控制会覆盖所有继承下来的访问控制。 缺省情况下,没有人对版本库有任何访问,这意味着如果你已经从一个空文件开始,你会希望给所有用户对版本库根目录具备读权限,你可以使用星号( [/] * = r 这是一个普通的设置;注意在小节名中没有提到版本库名称,这让所有版本库对所有的用户可读。当所有用户对版本库有了读权利,你可以赋予特定用户对特定子目录的 星号( 访问文件也允许你定义一组的用户,很像Unix的 [groups] calc-developers = harry, sally, joe paint-developers = frank, sally, jane everyone = harry, sally, joe, frank, sally, jane 组可以被赋予通用户一样的访问权限,使用“at”( [calc:/projects/calc] @calc-developers = rw [paint:/projects/paint] @paint-developers = rw jane = r 组中也可以定义为包含其它的组: [groups] calc-developers = harry, sally, joe paint-developers = frank, sally, jane everyone = @calc-developers, @paint-developers 参考:02 septiembre MySQL优化实例在Apache, PHP, MySQL的体系架构中,MySQL对于性能的影响最大,也是关键的核心部分。对于Discuz!论坛程序也是如此,MySQL的设置是否合理优化,直接影响到论坛的速度和承载量!同时,MySQL也是优化难度最大的一个部分,不但需要理解一些MySQL专业知识,同时还需要长时间的观察统计并且根据经验进行判断,然后设置合理的参数。 下面我们了解一下MySQL优化的一些基础,MySQL的优化我分为两个部分,一是服务器物理硬件的优化;二是MySQL自身(my.cnf)的优化。 (1) 服务器硬件对MySQL性能的影响 a) 磁盘寻道能力(磁盘I/O),以目前高转速SCSI硬盘(7200转/秒)为例,这种硬盘理论上每秒寻道7200次,这是物理特性决定的,没有办法改变。MySQL每秒钟都在进行大量、复杂的查询操作,对磁盘的读写量可想而知。所以,通常认为磁盘I/O是制约MySQL性能的最大因素之一,对于日均访问量在100万PV以上的Discuz!论坛,由于磁盘I/O的制约,MySQL的性能会非常低下!解决这一制约因素可以考虑以下几种解决方案: 使用RAID-0+1磁盘阵列,注意不要尝试使用RAID-5,MySQL在RAID-5磁盘阵列上的效率不会像你期待的那样快; 抛弃传统的硬盘,使用速度更快的闪存式存储设备。经过Discuz!公司技术工程的测试,使用闪存式存储设备可比传统硬盘速度高出6-10倍左右。 b) CPU 对于MySQL应用,推荐使用S.M.P.架构的多路对称CPU,例如:可以使用两颗Intel Xeon 3.6GHz的CPU。 c) 物理内存对于一台使用MySQL的Database Server来说,服务器内存建议不要小于2GB,推荐使用4GB以上的物理内存。 (2) MySQL自身因素当解决了上述服务器硬件制约因素后,让我们看看MySQL自身的优化是如何操作的。对MySQL自身的优化主要是对其配置文件my.cnf中的各项参数进行优化调整。下面我们介绍一些对性能影响较大的参数。 由于my.cnf文件的优化设置是与服务器硬件配置息息相关的,因而我们指定一个假想的服务器硬件环境: CPU: 2颗Intel Xeon 2.4GHz 内存: 4GB DDR 硬盘: SCSI 73GB 下面,我们根据以上硬件配置结合一份已经优化好的my.cnf进行说明: # vi /etc/my.cnf 以下只列出my.cnf文件中[mysqld]段落中的内容,其他段落内容对MySQL运行性能影响甚微,因而姑且忽略。 [mysqld] port = 3306 serverid = 1 socket = /tmp/mysql.sock skip-locking # 避免MySQL的外部锁定,减少出错几率增强稳定性。 skip-name-resolve 禁止MySQL对外部连接进行DNS解析,使用这一选项可以消除MySQL进行DNS解析的时间。但需要注意,如果开启该选项,则所有远程主机连接授权都要使用IP地址方式,否则MySQL将无法正常处理连接请求! back_log = 384 指定MySQL可能的连接数量。当MySQL主线程在很短的时间内接收到非常多的连接请求,该参数生效,主线程花费很短的时间检查连接并且启动一个新线程。 back_log参数的值指出在MySQL暂时停止响应新请求之前的短时间内多少个请求可以被存在堆栈中。 如果系统在一个短时间内有很多连接,则需要增大该参数的值,该参数值指定到来的TCP/IP连接的侦听队列的大小。不同的操作系统在这个队列大小上有它自己的限制。 试图设定back_log高于你的操作系统的限制将是无效的。默认值为50。对于Linux系统推荐设置为小于512的整数。 key_buffer_size = 256M # key_buffer_size指定用于索引的缓冲区大小,增加它可得到更好的索引处理性能。 查询排序时所能使用的缓冲区大小。注意:该参数对应的分配内存是每连接独占!如果有100个连接,那么实际分配的总共排序缓冲区大小为100 × 6 = 600MB。所以,对于内存在4GB左右的服务器推荐设置为6-8M。 read_buffer_size = 4M 读查询操作所能使用的缓冲区大小。和sort_buffer_size一样,该参数对应的分配内存也是每连接独享! join_buffer_size = 8M 联合查询操作所能使用的缓冲区大小,和sort_buffer_size一样,该参数对应的分配内存也是每连接独享! myisam_sort_buffer_size = 64M
table_cache = 512
thread_cache_size = 64
query_cache_size = 64M
指定MySQL查询缓冲区的大小。可以通过在MySQL控制台执行以下命令观察: # > SHOW VARIABLES LIKE '%query_cache%'; # > SHOW STATUS LIKE 'Qcache%'; # 如果Qcache_lowmem_prunes的值非常大,则表明经常出现缓冲不够的情况; 如果Qcache_hits的值非常大,则表明查询缓冲使用非常频繁,如果该值较小反而会影响效率,那么可以考虑不用查询缓冲;Qcache_free_blocks,如果该值非常大,则表明缓冲区中碎片很多。 tmp_table_size = 256M
max_connections = 768
指定MySQL允许的最大连接进程数。如果在访问论坛时经常出现Too Many Connections的错误提 示,则需要增大该参数值。 max_connect_errors = 10000000
wait_timeout = 10
指定一个请求的最大连接时间,对于4GB左右内存的服务器可以设置为5-10。 thread_concurrency = 8 该参数取值为服务器逻辑CPU数量×2,在本例中,服务器有2颗物理CPU,而每颗物理CPU又支持H.T超线程,所以实际取值为4 × 2 = 8 skip-networking 开启该选项可以彻底关闭MySQL的TCP/IP连接方式,如果WEB服务器是以远程连接的方式访问MySQL数据库服务器则不要开启该选项!否则将无法正常连接!
参考:http://kb.discuz.net/index.php?title=MySQL%E4%BC%98%E5%8C%96%E5%AE%9E%E4%BE%8B 21 julio UserType for persisting a Typesafe Enumeration with a VARCHAR column [转]Use this Typesafe Enumeration class in your domain model as a simple property type (e.g. of the Comment class in a forum): public class Rating implements Serializable {
private String name;
public static final Rating EXCELLENT = new Rating("Excellent");
public static final Rating OK = new Rating("OK");
public static final Rating LOW = new Rating("Low");
private static final Map INSTANCES = new HashMap();
static {
INSTANCES.put(EXCELLENT.toString(), EXCELLENT);
INSTANCES.put(OK.toString(), OK);
INSTANCES.put(LOW.toString(), LOW);
}
private Rating(String name) {
this.name=name;
}
public String toString() {
return name;
}
private Object readResolve() {
return getInstance(name);
}
public static Rating getInstance(String name) {
return (Rating)INSTANCES.get(name);
}
}
Next, write the Hibernate custom mapping type: public class RatingUserType implements UserType {
private static final int[] SQL_TYPES = {Types.VARCHAR};
public int[] sqlTypes() { return SQL_TYPES; }
public Class returnedClass() { return Rating.class; }
public boolean equals(Object x, Object y) { return x == y; }
public Object deepCopy(Object value) { return value; }
public boolean isMutable() { return false; }
public Object nullSafeGet(ResultSet resultSet,
String[] names,
Object owner)
throws HibernateException, SQLException {
String name = resultSet.getString(names[0]);
return resultSet.wasNull() ? null : Rating.getInstance(name);
}
public void nullSafeSet(PreparedStatement statement,
Object value,
int index)
throws HibernateException, SQLException {
if (value == null) {
statement.setNull(index, Types.VARCHAR);
} else {
statement.setString(index, value.toString());
}
}
}
Finally, in your mapping files, bind it all together: <hibernate-mapping package="org.hibernate.auction.model">
<class name="Comment"
table="COMMENTS"
lazy="true">
<!-- Common id property. -->
<id name="id"
type="long"
column="COMMENT_ID"
unsaved-value="null">
<generator class="native"/>
</id>
<!-- Simple property. -->
<property
name="rating"
column="RATING"
type="org.hibernate.auction.persistence.RatingUserType"
not-null="true"
update="false"/>
...
</class>
</hibernate-mapping>
You may also use your Rating enumerated type in Hibernate queries: Query q = session.createQuery("from Comment c where c.rating = :rating");
q.setParameter("rating",
Rating.LOW,
Hibernate.custom(RatingUserType.class));
This is all there is to know about it. You may enhance this strategy with a generic UserType implementation, that knows how to persist different Typesafe Enumerations, this is described here. The examples and domain model you have just seen can be found in Hibernate in Action. Christian Reference: 1. http://www.hibernate.org/172.html 枚举类型的映射和表示 [转]在项目中常遇到用数字表示一种意思的字段,例如:type ,1 表示正常状态,0表示冻结状态;这是一类典型的问题,即枚举类型的映射和表示。在Hibernate2.1版本中提供了enum的接口类型来处理这类问题,参考这个讨论: http://forum.javaeye.com/viewtopic.php?t=8114&postdays=0&postorder=asc&highlight=enum&start=0 但是在Hibernate3中取消了enum类型的支持,Hibernate官方推荐使用UserType接口。不过使用UserType接口实际上会比较复杂,下面我将使用一个简单的案例来讲解使用UserType接口来解决这类问题的办法:
package com.javaeye.simple.domain; import java.io.Serializable; public class UserTitle implements Serializable { private int title; public static final UserTitle EMPLOYEE = new UserTitle(0); public static final UserTitle MANAGER = new UserTitle(1); public static final UserTitle DIRECTOR = new UserTitle(2); public static final UserTitle CEO = new UserTitle(3); private UserTitle(int title) { public int toInt() { public static UserTitle fromInt(int title) { public String toString() { } 注意,我们需要一个UserTitleType的类,实现UserType接口,定义一个User对象的UserTitle属性是如何向数据库持久化的: package com.javaeye.simple.domain; import java.io.Serializable; import org.hibernate.HibernateException; public class UserTitleType implements UserType { public int[] sqlTypes() { public Class returnedClass() { public boolean equals(Object x, Object y) throws HibernateException { public int hashCode(Object x) throws HibernateException { public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException { public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException { public Object deepCopy(Object value) throws HibernateException { public boolean isMutable() { public Serializable disassemble(Object value) throws HibernateException { public Object assemble(Serializable cached, Object owner) throws HibernateException { public Object replace(Object original, Object target, Object owner) throws HibernateException { } 注意nullSafeGet和nullSafeSet方法的代码,是如何实现UserTitle的字符串值和数据库中保存数字进行转换的。 <?xml version="1.0"?> <hibernate-mapping package="com.javaeye.simple.domain"> <class name="User"> 指明title属性是用户自定义的某类型。 在Java程序中指定user的title属性:
18 julio 深树1. deeptree.jsp中定义css为deeptree.css,并定义<div id="deeptree" class="deeptree" CfgXMLSrc="deeptreeconfig.xml"> 参考:1. Deeptree下载 17 julio Keycode对照表
应用:1.限制输入数字 <input style="ime-mode : disabled" onKeyPress="if ((event.keyCode<48 || event.keyCode>57)) event.returnValue=false"> 参考:1. Keycode对照表 09 julio SSL Configuration HOW-TO
Reference: 04 julio eclipse内置resin的方法此配置适用于Resin2.x和Resin3.x版本。运行时需要在每个project目录下放置一个resin.conf文件,由于Resin2.x和Resin3.x版本的配置文件不同,所以需要两个文件,resin.conf文件用于启动resin2.x,resin30.conf用于启动resin3.x。 以下说明以配置Resin2.1.16版本为例,具体步骤如下: 29 mayo 修改Oracle9i中XDB的http和ftp服务端口安装Oracle 9i,其安装缺省包含了XDB。在启动数据库后,Oracle XDB的http服务将会自动占用了8080端口,使用下面方法修改XDB的http和ftp服务端口: 1.使用dbms_xdb包修改端口设置 使用sys登录sqlplus sqlplus sys/syspassword as sysdba 执行如下的脚本: ============================ -- Change the HTTP/WEBDAV port from 8080 to 8081 call dbms_xdb.cfg_update(updateXML( dbms_xdb.cfg_get() , '/xdbconfig/sysconfig/protocolconfig/httpconfig/http-port/text()' , 8081)) / -- Change the FTP port from 2100 to 2111 call dbms_xdb.cfg_update(updateXML( dbms_xdb.cfg_get() , '/xdbconfig/sysconfig/protocolconfig/ftpconfig/ftp-port/text()' , 2111)) / COMMIT; EXEC dbms_xdb.cfg_refresh; 参考 20 noviembre Hierarchical QueriesCONNECT BY Example The following hierarchical query uses the SELECT employee_id, last_name, manager_id FROM employees CONNECT BY PRIOR employee_id = manager_id;
START WITH Examples The next example adds a SELECT last_name, employee_id, manager_id, LEVEL
FROM employees
START WITH employee_id = 100
CONNECT BY PRIOR employee_id = manager_id
ORDER SIBLINGS BY last_name;23 agosto MelodiesRETURN TO SOLITUDE Robert Bly It is a moonlit, windy night. We want to go back, to return to the sea, What shall we find when we return? from Silence in the Snowy Fields (1962)
One Fine Spring Day MV [Main Theme] 22 agosto The Isle - Percy Bysshe ShelleyThere was a little lawny islet
小岛 有一座小岛,细草如茵, Alice in WonderlandChapter I - Down the Rabbit-Hole
So she was considering in her own mind (as well as she could, for the hot day made her feel very sleepy and stupid), whether the pleasure of making a daisy-chain would be worth the trouble of getting up and picking the daisies, when suddenly a White Rabbit with pink eyes ran close by her. There was nothing so very remarkable in that; nor did Alice think it so very much out of the way to hear the Rabbit say to itself, 'Oh dear! Oh dear! I shall be late!' (when she thought it over afterwards, it occurred to her that she ought to have wondered at this, but at the time it all seemed quite natural); but when the Rabbit actually took a watch out of its waistcoat-pocket, and looked at it, and then hurried on, Alice started to her feet, for it flashed across her mind that she had never before seen a rabbit with either a waistcoat-pocket, or a watch to take out of it, and burning with curiosity, she ran across the field after it, and fortunately was just in time to see it pop down a large rabbit-hole under the hedge. In another moment down went Alice after it, never once considering how in the world she was to get out again. The rabbit-hole went straight on like a tunnel for some way, and then dipped suddenly down, so suddenly that Alice had not a moment to think about stopping herself before she found herself falling down a very deep well. Either the well was very deep, or she fell very slowly, for she had plenty of time as she went down to look about her and to wonder what was going to happen next. First, she tried to look down and make out what she was coming to, but it was too dark to see anything; then she looked at the sides of the well, and noticed that they were filled with cupboards and book-shelves; here and there she saw maps and pictures hung upon pegs. She took down a jar from one of the shelves as she passed; it was labelled 'ORANGE MARMALADE', but to her great disappointment it was empty: she did not like to drop the jar for fear of killing somebody, so managed to put it into one of the cupboards as she fell past it. 'Well!' thought Alice to herself, 'after such a fall as this, I shall think nothing of tumbling down stairs! How brave they'll all think me at home! Why, I wouldn't say anything about it, even if I fell off the top of the house!' (Which was very likely true.) Down, down, down. Would the fall never come to an end! 'I wonder how many miles I've fallen by this time?' she said aloud. 'I must be getting somewhere near the centre of the earth. Let me see: that would be four thousand miles down, I think--' (for, you see, Alice had learnt several things of this sort in her lessons in the schoolroom, and though this was not a very good opportunity for showing off her knowledge, as there was no one to listen to her, still it was good practice to say it over) '--yes, that's about the right distance -- but then I wonder what Latitude or Longitude I've got to?' (Alice had no idea what Latitude was, or Longitude either, but thought they were nice grand words to say.) Presently she began again. 'I wonder if I shall fall right through the earth! How funny it'll seem to come out among the people that walk with their heads downward! The Antipathies, I think--' (she was rather glad there was no one listening, this time, as it didn't sound at all the right word) '--but I shall have to ask them what the name of the country is, you know. Please, Ma'am, is this New Zealand or Australia?' (and she tried to curtsey as she spoke -- fancy curtseying as you're falling through the air! Do you think you could manage it?) 'And what an ignorant little girl she'll think me for asking! No, it'll never do to ask: perhaps I shall see it written up somewhere.' Down, down, down. There was nothing else to do, so Alice soon began talking again. 'Dinah'll miss me very much to-night, I should think!' (Dinah was the cat.) 'I hope they'll remember her saucer of milk at tea-time. Dinah my dear! I wish you were down here with me! There are no mice in the air, I'm afraid, but you might catch a bat, and that's very like a mouse, you know. But do cats eat bats, I wonder?' And here Alice began to get rather sleepy, and went on saying to herself, in a dreamy sort of way, 'Do cats eat bats? Do cats eat bats?' and sometimes, 'Do bats eat cats?' for, you see, as she couldn't answer either question, it didn't much matter which way she put it. She felt that she was dozing off, and had just begun to dream that she was walking hand in hand with Dinah, and saying to her very earnestly, 'Now, Dinah, tell me the truth: did you ever eat a bat?' when suddenly, thump! thump! down she came upon a heap of sticks and dry leaves, and the fall was over. Alice was not a bit hurt, and she jumped up on to her feet in a moment: she looked up, but it was all dark overhead; before her was another long passage, and the White Rabbit was still in sight, hurrying down it. There was not a moment to be lost: away went Alice like the wind, and was just in time to hear it say, as it turned a corner, 'Oh my ears and whiskers, how late it's getting!' She was close behind it when she turned the corner, but the Rabbit was no longer to be seen: she found herself in a long, low hall, which was lit up by a row of lamps hanging from the roof. There were doors all round the hall, but they were all locked; and when Alice had been all the way down one side and up the other, trying every door, she walked sadly down the middle, wondering how she was ever to get out again. Suddenly she came upon a little three-legged table, all made of solid glass; there was nothing on it except a tiny golden key, and Alice's first thought was that it might belong to one of the doors of the hall; but, alas! either the locks were too large, or the key was too small, but at any rate it would not open any of them. However, on the second time round, she came upon a low curtain she had not noticed before, and behind it was a little door about fifteen inches high: she tried the little golden key in the lock, and to her great delight it fitted! Alice opened the door and found that it led into a small passage, not much larger than a rat-hole: she knelt down and looked along the passage into the loveliest garden you ever saw. How she longed to get out of that dark hall, and wander about among those beds of bright flowers and those cool fountains, but she could not even get her head though the doorway; 'and even if my head would go through,' thought poor Alice, 'it would be of very little use without my shoulders. Oh, how I wish I could shut up like a telescope! I think I could, if I only know how to begin.' For, you see, so many out-of-the-way things had happened lately, that Alice had begun to think that very few things indeed were really impossible. There seemed to be no use in waiting by the little door, so she went back to the table, half hoping she might find another key on it, or at any rate a book of rules for shutting people up like telescopes: this time she found a little bottle on it, ('which certainly was not here before,' said Alice,) and round the neck of the bottle was a paper label, with the words 'DRINK ME' beautifully printed on it in large letters. It was all very well to say 'Drink me,' but the wise little Alice was not going to do that in a hurry. 'No, I'll look first,' she said, 'and see whether it's marked "poison" or not'; for she had read several nice little histories about children who had got burnt, and eaten up by wild beasts and other unpleasant things, all because they would not remember the simple rules their friends had taught them: such as, that a red-hot poker will burn you if you hold it too long; and that if you cut your finger very deeply with a knife, it usually bleeds; and she had never forgotten that, if you drink much from a bottle marked 'poison,' it is almost certain to disagree with you, sooner or later. However, this bottle was not marked 'poison,' so Alice ventured to taste it, and finding it very nice, (it had, in fact, a sort of mixed flavour of cherry-tart, custard, pine-apple, roast turkey, toffee, and hot buttered toast,) she very soon finished it off. 'What a curious feeling!' said Alice; 'I must be shutting up like a telescope.' And so it was indeed: she was now only ten inches high, and her face brightened up at the thought that she was now the right size for going through the little door into that lovely garden. First, however, she waited for a few minutes to see if she was going to shrink any further: she felt a little nervous about this; 'for it might end, you know,' said Alice to herself, 'in my going out altogether, like a candle. I wonder what I should be like then?' And she tried to fancy what the flame of a candle is like after the candle is blown out, for she could not remember ever having seen such a thing. After a while, finding that nothing more happened, she decided on going into the garden at once; but, alas for poor Alice! when she got to the door, she found she had forgotten the little golden key, and when she went back to the table for it, she found she could not possibly reach it: she could see it quite plainly through the glass, and she tried her best to climb up one of the legs of the table, but it was too slippery; and when she had tired herself out with trying, the poor little thing sat down and cried. 'Come, there's no use in crying like that!' said Alice to herself, rather sharply; 'I advise you to leave off this minute!' She generally gave herself very good advice, (though she very seldom followed it), and sometimes she scolded herself so severely as to bring tears into her eyes; and once she remembered trying to box her own ears for having cheated herself in a game of croquet she was playing against herself, for this curious child was very fond of pretending to be two people. 'But it's no use now,' thought poor Alice, 'to pretend to be two people! Why, there's hardly enough of me left to make one respectable person!' Soon her eye fell on a little glass box that was lying under the table: she opened it, and found in it a very small cake, on which the words 'EAT ME' were beautifully marked in currants. 'Well, I'll eat it,' said Alice, 'and if it makes me grow larger, I can reach the key; and if it makes me grow smaller, I can creep under the door; so either way I'll get into the garden, and I don't care which happens!' She ate a little bit, and said anxiously to herself, 'Which way? Which way?', holding her hand on the top of her head to feel which way it was growing, and she was quite surprised to find that she remained the same size: to be sure, this generally happens when one eats cake, but Alice had got so much into the way of expecting nothing but out-of-the-way things to happen, that it seemed quite dull and stupid for life to go on in the common way. So she set to work, and very soon finished off the cake. 15 agosto Prototype JavaScript Framework Review (Cont'd)String.prototype 的扩展: strip: function() { Introduction to Ajax |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|