posts - 10, comments - 9, trackbacks - 0, articles - 17

2010年7月7日

[ERROR] 07-29 11:23 - The /WEB-INF/web.xml was not found.  (ActionServlet.java:1787)
java.net.ConnectException: Connection timed out: connect

原web.xml头部:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>




  <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>


修改为
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi
="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation
="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">




  
<servlet>
    
<servlet-name>action</servlet-name>
    
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>

posted @ 2010-07-29 11:23 wesley1987 阅读(1476) | 评论 (0)编辑 收藏


在tomcat等容器中发布带velocity的应用时, 出现 org.apache.velocity.exception.ResourceNotFoundException : Unable to find resource ...vm  的解决办法:

配置文件 velocity.properties 中, 如果有
resource.loader = file

file
.resource.loader.description = Velocity File Resource Loader
file
.resource.loader.class = org.apache.velocity.runtime.resource.loader.FileResourceLoader
file
.resource.loader.path = .
file
.resource.loader.cache = false
file
.resource.loader.modificationCheckInterval = 2

这段, 全部注释掉即可.

若没有, 就在配置里写上以上内容, 并更改第三项为

file.resource.loader.class = org.apache.velocity.tools.view.WebappResourceLoader

posted @ 2010-07-28 15:35 wesley1987 阅读(14018) | 评论 (1)编辑 收藏

1。指定velocity.properties文件,  默认路径为 WEB-INF/velocity.properties 也可自定义路径, 在web.xml中
      <servlet>
        
<servlet-name>velocity</servlet-name>
        
<servlet-class>org.apache.velocity.tools.view.servlet.VelocityLayoutServlet</servlet-class>
        
<init-param>
            
<param-name>org.apache.velocity.properties</param-name>
            
<param-value>/WEB-INF/config/velocity.properties</param-value>
        
</init-param>
        
<init-param>
            
<param-name>org.apache.velocity.toolbox</param-name>
            
<param-value>/WEB-INF/config/velocity-toolbox.xml</param-value>
        
</init-param>
        
<load-on-startup>5</load-on-startup>
      
</servlet>
注意 load-on-startup 需要配置且靠后, 否则启动时看不到日志.

2。在velocity.properties中配置日程相关参数:
#----------------------------------------------------------------------------
#  default LogSystem to use: default: AvalonLogSystem
#----------------------------------------------------------------------------


runtime
.log.logsystem.class = org.apache.velocity.runtime.log.SimpleLog4JLogSystem

runtime
.log.logsystem.log4j.category = velocity_log

#----------------------------------------------------------------------------
# This controls if Runtime.error(), info() and warn() messages include the
# whole stack trace. The last property controls whether invalid references
# are logged.
#----------------------------------------------------------------------------


runtime
.log.error.stacktrace = false
runtime
.log.warn.stacktrace = false
runtime
.log.info.stacktrace = false
runtime
.log.invalid.reference = true


3\ 配置log4j.properties,  具体配置意义请参看log4j配置相关文档
log4j.rootLogger=INFO,CONSOLE,FILE
log4j
.logger.velocity_log=INFO,CONSOLE,VELOCITY
log4j
.addivity.org.apache=true

log4j
.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j
.appender.CONSOLE.Threshold=WARN
log4j
.appender.CONSOLE.Target=System.out
log4j
.appender.CONSOLE.Encoding=GBK
log4j
.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j
.appender.CONSOLE.layout.ConversionPattern=[%-4p] %d{MM-dd HH:mm} - %m  %n

log4j
.appender.VELOCITY=org.apache.log4j.FileAppender
log4j
.appender.VELOCITY.File=E:/workspace/dwrt/WebRoot/log/velocity.log
log4j
.appender.VELOCITY.Append=false
log4j
.appender.VELOCITY.Encoding=GBK
log4j
.appender.VELOCITY.layout=org.apache.log4j.PatternLayout
log4j
.appender.VELOCITY.layout.ConversionPattern=[%-4p] %d{MM-dd HH:mm} - %m  %n

posted @ 2010-07-28 11:39 wesley1987 阅读(2445) | 评论 (0)编辑 收藏

select COUNT(*) from table t WHERE t.col <> '3'


SELECT COUNT(*) FROM table t WHERE t.col NOT IN
(select t.col from table t WHERE t.col= '3')

以上两句SQL的执行结果不同, 因为 <> 在排除3的同时, 将null也排除了,
所以当比较字段含null时,第一句将比第二句的结果少.

当然第二句从效率上来说不是一个好的写法, 这样写只是为了理解, 在第一句后面, 加上 or t.col is null 应该就等效了.

posted @ 2010-07-07 10:17 wesley1987 阅读(7279) | 评论 (1)编辑 收藏

在js中写了个替换字符的句子, 然后才知道原来js没有replaceAll方法, 就是说用replace的话, 他自会替换一次.

自定义replaceAll方法,
String.prototype.replaceAll  = function(s1,s2){    
        return this.replace(new RegExp(s1,"gm"),s2);   
}  

gm     g=global, m=multiLine  , 

或直接 string = string..replace(new RegExp(s1,"gm"),s2);   

posted @ 2010-07-07 09:44 wesley1987 阅读(1058) | 评论 (0)编辑 收藏