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

          2008年12月4日

          [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 閱讀(1521) | 評論 (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 閱讀(14196) | 評論 (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 閱讀(2480) | 評論 (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 閱讀(7312) | 評論 (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 閱讀(1080) | 評論 (0)編輯 收藏

          在使用DispatchAction時出現了這個問題,從這句話分析,就是沒有在指定的類中,找到對應的方法。

          先說結論: 在Action中定義的方法(要在參數中使用的方法),參數一定要固定為
          (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response )

          --------------------------------
          這種錯誤,一般在保證所有路徑的拼寫都正確的情況下應該就能避免,

          那接著分析一下,struts是如何從jsp一步步找到這個方法呢?


          1 頁面上 action的路徑,以及對應的struts配置文件中定義的parameter的參數名(我這叫method)屬性值,這個屬性值應對應著 Action類的方法名。

          2 確認了以上路徑都正確的情況下,考慮到DispatchAction對應“方法”的方式,發現原來是方法多了一個參數。

          順便看了下DispatchAction源代碼,看到里面找方法的時候,用的是
           method = clazz.getMethod(name, types);
          其中
          clazz = getClass();
          types = (new Class[] {
                      org.apache.struts.action.ActionMapping.class,  org.apache.struts.action.ActionForm.class,  javax.servlet.http.HttpServletRequest.class,  javax.servlet.http.HttpServletResponse.class
                  });

          就是說,DispatchAction只會將參數固定為以上4中的函數作為控制器方法使用。

          posted @ 2009-07-27 21:13 wesley1987 閱讀(4253) | 評論 (2)編輯 收藏

               摘要: ActionForm繼承了下ForwardConfig,然后就寫了6個構造函數……然后就沒了 =。=!
          有一句話沒翻譯出來,有看得懂的來幫個忙吧 :
          NOTE - This class would have been deprecated and
          replaced by org.apache.struts.config.ForwardConfig except for the fact that
          it is part of the public API that existing applications are using.
          下面是翻譯后的源碼。
          package org.apache.struts.action
            閱讀全文

          posted @ 2008-12-10 15:53 wesley1987 閱讀(551) | 評論 (0)編輯 收藏

               摘要: package org.apache.struts.action.ActionForm源代碼(注釋翻譯版)

          *一個ActionForm是可以與一個或多個任意的ActionMapping關聯的JavaBean。這個bean的里屬性
          * 在對應Action.execute方法調用前,由對應的request初始化。
          *
          * 當這個bean的屬性被賦值后,Action.execute方法調用之前,bean的validate方法
          * 將被調用,這個方法用來校驗用戶提交的屬性值。如果發現錯誤,就返回一個包含了這些錯誤內容的
          * error信息。controller將返回至相應的輸入表單。如果無錯誤,validate方法就返回null,
          * 相應的Action.execute方法將被調用。
          *  閱讀全文

          posted @ 2008-12-09 21:48 wesley1987 閱讀(687) | 評論 (0)編輯 收藏

               摘要:   閱讀全文

          posted @ 2008-12-09 19:22 wesley1987 閱讀(697) | 評論 (0)編輯 收藏

               摘要:   閱讀全文

          posted @ 2008-12-09 18:31 wesley1987 閱讀(3480) | 評論 (0)編輯 收藏

          主站蜘蛛池模板: 湘阴县| 德钦县| 淅川县| 盐亭县| 黎平县| 鹰潭市| 克拉玛依市| 云南省| 崇州市| 琼结县| 根河市| 林芝县| 道真| 兰州市| SHOW| 军事| 齐齐哈尔市| 正阳县| 河池市| 恩平市| 明光市| 文安县| 高平市| 永平县| 罗平县| 衡山县| 满洲里市| 渭源县| 鹤壁市| 澜沧| 夹江县| 揭西县| 汽车| 庆云县| 北辰区| 宜黄县| 绵竹市| 密云县| 兴城市| 郎溪县| 滨州市|