<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    無聊人士

    搬家==》www.soapui.cn

      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      32 隨筆 :: 0 文章 :: 60 評論 :: 0 Trackbacks

    2006年2月7日 #

    struts 2.0.6GA開始試螃蟹,照著struts2的tag文檔寫成<@s.datetimepicker/>,結果老是報錯
    211672?[http-8080-Processor25]?ERROR?freemarker.runtime??-?
    on?line?
    7,?column?17?in?admin/index.ftl?s.datetimepicker?not?found.
    The?problematic?instruction:
    ----------
    ==>?user-directive?s.datetimepicker?[on?line?7,?column?17?in?admin/index.ftl]
    ----------

    Java?backtrace?for?programmers:
    ----------
    freemarker.core.InvalidReferenceException:?on?line?
    7,?column?17?in?admin/index.ftl?s.datetimepicker?not?found.

    試著google一下,正好有人也提交了這個bug,改成 <@s.dateTimePicker />,問題解決

    The?fix?is?as?follows:

    In?struts2-core-
    2.0.6:
    org.apache.struts2.views.freemarker.tags.StrutsModels

    has?a?method
    getDateTimePicker()

    Which?should?be?re-named:
    getDatetimepicker()

    to?match?with?the?naming?convention.


    hello,struts2.jpg
    posted @ 2007-04-20 10:26 mmwy 閱讀(2596) | 評論 (0)編輯 收藏

    來自:http://www.javaworld.com.tw/jute/post/print?bid=11&id=166588

    3.Re:BIRT報表工具的問題?[Re:?uxa]?????Copy?to?clipboard
    Posted?by:?uxa
    Posted?on:?
    2006-09-15?15:28

    經過幾次的失敗後~~小弟終於試出來了
    不過感覺它似乎只是support?xls?file?format並沒有excel的一些功能>?<

    1.?download?eclipse?plugin?BIRT,小弟抓的是birt-report-designer-all-in-one-2_1_0.zip
    將其解開後把eclipse\plugins和eclipse\features這兩個目錄放到eclipse的目錄底下
    現在將eclipse打開,您已經可以開始設計報表了。

    2.?BIRT預設有支援HTML和PDF的格式,以下說明如何支援xls格式
    a.?download?xls-emitter-bin_2
    .1.0.zip,解開後將plugins複製到eclipse\plugins下
    b.?download?poi-bin-
    3.0-alpha2-20060616.zip,解開後將jar檔複製到eclipse\plugins\?org.uguess.birt.report.engine.emitter.xls_2.1.0.200607031206\lib
    c.?xls-emitter-bin_2
    .1.0.zip解開後有個path的目錄,
    (
    1)?將org.eclipse.birt.report.designer.ui目錄下的檔案複製到eclipse\plugins\org.eclipse.birt.report.designer.ui.preview_2.1.0.*.jar
    (
    2)將org.eclipse.birt.report.viewer目錄下的檔案複製到eclipse\plugins\?org.eclipse.birt.report.viewer_2.1.0.*\birt\WEB-INF\lib\viewservlets.jar
    (
    3)將org.eclipse.birt.report.engine目錄下的檔案複製到eclipse\plugins\org.eclipse.birt.report.engine_2.1.0.*.jar

    完成後啟動eclipse可看到在view?report的按鈕上多了xls和ppt兩種格式

    BIRT下載位置:http://download.eclipse.org/birt/downloads/
    Tribix下載位置:https://sourceforge.net/projects/tribix
    ps:請注意版本的問題,BIRT2
    .1.0請搭配Tribix?XLS?Emitter?2.1.0版本,在置換檔名的部份也請注意路徑是否正確

    posted @ 2007-04-08 15:42 mmwy 閱讀(1624) | 評論 (2)編輯 收藏

    條碼顯示,在birt中最常見的有兩種方法:1、使用條碼字體(對pdf無效);2、用barcode的開源包,生成barcode,然后在報表里用動態地址去取圖片。

    今晚看birt文檔(第 23 章 使用 Java 編寫事件處理程序),例子中用java實現了一個LabelEventAdapter的適配器,對標簽元素進行事件控制。腦子里靈光一現,似乎條碼有著落了。

    我的測試例子很簡單,繼承ImageEventAdapter類,重載onCreate方法,以進行條形碼處理

    ?1?package?cn.ynzc.common.birt.test;
    ?2?
    ?3?import?java.io.File;
    ?4?import?java.io.FileOutputStream;
    ?5?
    ?6?import?jbarcodebean.Code128;
    ?7?import?jbarcodebean.JBarcodeBean;
    ?8?
    ?9?import?org.apache.commons.codec.digest.DigestUtils;
    10?import?org.eclipse.birt.report.engine.api.script.IReportContext;
    11?import?org.eclipse.birt.report.engine.api.script.eventadapter.ImageEventAdapter;
    12?import?org.eclipse.birt.report.engine.api.script.instance.IImageInstance;
    13?
    14?public?class?MyLabelClass?extends?ImageEventAdapter?{
    15?
    16???public?void?onCreate(IImageInstance?image,?IReportContext?reportContext)?{
    17?????try?{
    18???????//實際應用中,可以使用image.getRowData().getColumnValue("columnname")獲得字段值
    19???????String?code?=?"ABCDEF123-2222";
    20???????//似乎windows文件名中不允許使用“-”等符號,干脆將code進行md5散列處理
    21???????File?file?=?new?File(System.getProperty("java.io.tmpdir"),?DigestUtils.md5Hex(code));
    22???????//避免每次都進行條碼文件生成
    23???????if?(!file.exists())?{
    24?????????JBarcodeBean?bb?=?new?JBarcodeBean();
    25?????????bb.setCodeType(new?Code128());
    26?????????bb.setShowText(true);
    27?????????bb.setBarcodeHeight(45);?//條碼高度
    28?????????bb.setCode(code);
    29?????????bb.gifEncode(new?FileOutputStream(file));
    30???????}
    31???????image.setFile(file.getAbsolutePath());
    32?????}
    33?????catch?(Exception?e)?{
    34???????e.printStackTrace();
    35?????}
    36???}
    37?
    38?}
    39?

    測試用的birt報表文件簡單得要死,就往上面扔了個image元素,設置其Event Handler Class為剛才寫好的java類,最終得到的rptdesign文件內容如下:
    ?1?<?xml?version="1.0"?encoding="UTF-8"?>
    ?2?<!--?Written?by?Eclipse?BIRT?2.0?-->
    ?3?<report?xmlns="http://www.eclipse.org/birt/2005/design"?version="3.2.6"?id="1">
    ?4?????<property?name="createdBy">Eclipse?BIRT?Designer?Version?2.1.2.v20070205-1728?Build?&lt;20070205-1728></property>
    ?5?????<property?name="units">in</property>
    ?6?????<page-setup>
    ?7?????????<simple-master-page?name="Simple?MasterPage"?id="2"/>
    ?8?????</page-setup>
    ?9?????<body>
    10?????????<image?id="4">
    11?????????????<property?name="eventHandlerClass">cn.ynzc.common.birt.test.MyLabelClass</property>
    12?????????</image>
    13?????</body>
    14?</report>

    運行測試,條形碼出來了
    birt.jpg

    遺留問題:
    這次是調用org.eclipse.birt.report.engine.api.script.instance.IImageInstance.setFile()來解決問題,從javadoc可以看到,IImageInstance有很多方法可以調用,其它方法分別有什么作用?比如我嘗試了半天的setData(byte[])方法,一開始以為是用這個方法直接把圖形數據set進去就ok,結果未成功。


    posted @ 2007-04-07 03:37 mmwy 閱讀(4228) | 評論 (4)編輯 收藏

    birt的IRunAndRenderTask接口提供了addScriptableJavaObject(java.lang.String jsName, java.lang.Object obj)方法,利用這個方法,在直接調用birt api操作處理報表的時候,我們可以將任何java對象通過addScriptableJavaObject("xxx",Object)加進birt去,然后在birt腳本中直接調用xxx.method()進行操作。

    我的測試是在一個webwork+spring+hibernate的webapp應用中進行的,進行報表處理的代碼參照http://wiki.eclipse.org/index.php/Servlet_Example編寫,在代碼中,寫了一句
    task.addScriptableJavaObject("ctx",
    WebApplicationContextUtils.getWebApplicationContext(sc));

    birt中定義了一個scripts datasource,然后定義一個data set,在dataset的open方法中編寫腳本

    infoManager=ctx.getBean("infoManager");
    infos=infoManager.loadAll();
    ...
    posted @ 2007-04-06 15:39 mmwy 閱讀(2062) | 評論 (3)編輯 收藏

    在apache網站上已經有很詳細的介紹
    http://tomcat.apache.org/connectors-doc/reference/iis.html

    有幾點注意的:
    1、除了照文檔的例子在注冊表"HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Jakarta Isapi Redirector\1.0"建相應鍵值外,還可以在isapi_redirect.dll所在的目錄建“isapi_redirect.properties”文件。

    2、extension_uri=/jakarta/isapi_redirect.dll
    這個extension_uri寫成什么路徑,就得在iis站點中建相應名字的虛擬目錄(執行權限),以保證/jakarta/isapi_redirect.dll能被正常訪問到。

    3、除文檔上介紹的幾大步(注冊表、網站、虛擬路徑等)以外,win2003 iis上還得做下面這個步驟

    新建應用程序擴展
    在IIS管理器左側網站下面選中Web服務擴展,添加一個新的Web服務擴展,擴展名為jakarta,添加要求得文件為D:\Tomcat5.0\bin\jakart\isapi_redirect.dll,并設置擴展狀態為允許。
    (注:來自 http://www.cnrui.cn/blog/article.asp?id=179




    posted @ 2007-03-19 15:39 mmwy 閱讀(1834) | 評論 (2)編輯 收藏



    選中table的detail行,切換到script標簽,在onPrepare事件中輸入
    ?
    count=1;

    在onCreate事件中輸入
    1count++;
    2this.getStyle().backgroundColor=(count%2==0?"red":"blue");

    或是直接打開xml source,在相應的detail位置上修改源碼為
    ????????????????<detail>
    ??????????????????
    <row?id="66">
    ????????????????????.
    ????????????????????
    <method?name="onPrepare"><![CDATA[count=1;]]></method>
    ????????????????????
    <method?name="onCreate"><![CDATA[count++;this.getStyle().backgroundColor=(count%2==0?"red":"blue");]]></method>
    ????????????????????..

    xxxxx.jpg

    posted @ 2006-11-24 01:04 mmwy 閱讀(1880) | 評論 (0)編輯 收藏

    定義報表參數:

    3.jpg



    解決方法一:

    1.jpg


    2.jpg



    解決辦法二:

    在報表空白處點擊一下,然后切換到script標簽,選擇beforeFactory。

    4.jpg


    posted @ 2006-11-23 01:48 mmwy 閱讀(3286) | 評論 (0)編輯 收藏

    筆記一下:

    設hibernate.hbm2ddl.auto為update/create-drop/create后,在classpath中扔一個/import.sql進去,hibernate啟動時就會執行import.sql的內容。

    11860 [main] INFO? org.hibernate.tool.hbm2ddl.SchemaExport? - Running hbm2ddl schema export
    11860 [main] DEBUG org.hibernate.tool.hbm2ddl.SchemaExport? - import file not found: /import.sql
    11875 [main] INFO? org.hibernate.tool.hbm2ddl.SchemaExport? - exporting generated schema to database
    posted @ 2006-10-31 00:32 mmwy 閱讀(5763) | 評論 (2)編輯 收藏

    使用的安裝包:
    ?1?cronolog-1.6.2.tar.gz??????????????????????????????
    ?2httpd-2.0.59.tar.gz????????????????????????????????
    ?3instantclient-basic-linux32-10.2.0.2-20060331.zip??
    ?4instantclient-sdk-linux32-10.2.0.2-20060331.zip????
    ?5libmcrypt-2.5.7.tar.gz?????????????????????????????
    ?6mhash-0.9.7.1.tar.gz???????????????????????????????
    ?7mysql-3.23.58.tar.gz???????????????????????????????
    ?8php-4.4.4.tar.gz????

    參考文檔

    1. 為 Linux 和 Windows 安裝 PHP 和 Oracle 10g Instant Client
    2. Connecting to Oracle10g from PHP using OCI-8 (Linux)
    與文檔有出處的地方
    1. otn上只能下到zip格式的oracle 10g instant client basic和sdk包。解壓縮后,全部放到instantclient_10_2目錄下。
      [root@localhost?sdk]#?ls?-l?..
      total?
      115948
      -r--r--r--??
      1?root?root??1594191?Feb??5??2006?classes12.jar
      -rwxrwxr-x??
      2?root?root?18774535?Feb??5??2006?libclntsh.so
      -rwxrwxr-x??
      2?root?root?18774535?Feb??5??2006?libclntsh.so.10.1
      -r-xr-xr-x??
      1?root?root??5623929?Feb??5??2006?libnnz10.so
      -rwxrwxr-x??
      1?root?root??1398088?Feb??5??2006?libocci.so.10.1
      -rwxrwxr-x??
      1?root?root?70690282?Feb??5??2006?libociei.so
      -r-xr-xr-x??
      1?root?root???119919?Feb??5??2006?libocijdbc10.so
      -r--r--r--??
      1?root?root??1540457?Feb??5??2006?ojdbc14.jar
      drwxr-xr-x??
      4?root?root?????4096?Oct?17?04:27?sdk
      [root@localhost?sdk]#?ls?-l
      total?
      324
      drwxr-xr-x??
      2?root?root???4096?Oct?17?04:27?demo
      drwxr-xr-x??
      2?root?root???4096?Oct?17?04:27?include
      -r-xr-xr-x??
      1?root?root????346?Oct?17?04:27?ott
      -rw-r--r--??
      1?root?root?298274?Oct?17?04:27?ottclasses.zip
    2. php4.4.4已經提供了--with-oci8-instant-client參數的支持,同時修復了相關補丁,因此,文檔中為php打補丁、重建“configure”腳本的步驟可以省略。
    環境變量:
    1. 在LD_LIBRARY_PATH中添加oracle 10g instant client的路徑。
      export?LD_LIBRARY_PATH=/www/server/instantclient_10_2/:${LD_LIBRARY_PATH}
    2. 設置TNS_ADMIN為oracle tnsname.ora文件所在目錄。
      export?TNS_ADMIN=/u01/app/oracle/product/10g/network/admin/
    編譯腳本
    ./configure \
    --prefix
    =/www/server/php-4.4.4 \
    --with-apxs2
    =/www/server/httpd-2.0.59/bin/apxs \
    --with-mysql
    =/www/server/mysql-3.23.58 \
    --with-mcrypt
    =/www/server/libmcrypt-2.5.7 \
    --with-mhash
    =/www/server/mhash-0.9.7.1 \
    --with-gd?--with-zlib \
    --with-oci8-instant-client
    =/www/server/instantclient_10_2
    注:需要使用ln命令為libclntsh.so.10.1創建一個名為libclntsh.so的連接,否則在configure過程中將會出現error:Link xxxx not found的錯誤。(http://forums.oracle.com/forums/thread.jspa?messageID=1203218&#1203218

    測試
    1. 安裝成功的話,在phpinfo()信息中可以看到相應信息
      OCI8?Support????????????????? enabled
      Revision????????????????????? $Revision:?
      1.183.2.18.2.3?$
      Oracle?Version???????????????
      10.1
      Compile-time?ORACLE_HOME????? /www/server/instantclient_10_2
      Libraries?Used??????????????? no?value
    2. 測試代碼
      ?1?<?php?
      ?2?$conn?=?OCILogon("username",?"password",?"//127.0.0.1:1521/sid");
      ?3?$query?=?'select?table_name?from?user_tables';
      ?4?$stid?=?OCIParse($conn,?$query);
      ?5?OCIExecute($stid,?OCI_DEFAULT);
      ?6?
      ?7?while?($succ?=?OCIFetchInto($stid,?$row))?{
      ?8?????foreach?($row?as?$item)?{
      ?9?????????echo?$item."?";
      10?????????}
      11?????echo?"<br>\n";
      12??}
      13?OCILogoff($conn);
      14??>


    posted @ 2006-10-15 02:46 mmwy 閱讀(1336) | 評論 (1)編輯 收藏

    最近在“玩”hibernate Annotation,弄了個Attachment保存進數據庫的測試,附件內容保存在content屬性里面。
    ??@Lob
    ??@Column(columnDefinition?
    =?"LongBlob")
    ??
    public?byte[]?getContent()?{
    ????
    return?content;
    ??}
    一開始,配置mysql jdbc url如下
    jdbc.url????????????=????jdbc:mysql://localhost/test\
    ?????????????????????????????useUnicode
    =true\
    ????????????????????????????&characterEncoding
    =gbk
    一測試,報錯
    Caused?by:?java.sql.BatchUpdateException:?Syntax?error?or?access?violation?message?from?server:?"You?have?an?error?in?your?SQL?syntax?near?''D0CF11E0A1B11AE1000000000000000000000000000000003E000300FEFF0900060000000000000'?at?line?1"
    ????at?com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:
    1540)
    同樣的語句,直接在mysql命令行下運行就沒問題,偏偏jdbc上就有這臭毛病。換jdbc driver版本,改@Lob為 @Type(type = "org.springframework.orm.hibernate3.support.BlobByteArrayType"),改hibernate配置(比如hibernate.jdbc.use_streams_for_binary true),甚至是直接用jdbc來insert,亂七八糟折騰半天,問題照舊。最后只好用上“歪”招,把byte[]配成String,在保存的時候把byte[]保存成hex String格式,取的時候再解碼回來。

    歪招終歸是歪招,這兩天老為這東西心煩,晚上吃飯的時候無意中想起charset的問題,把代碼撿回來再測試了一下,問題解決,哈哈!
    jdbc.url????????????=????jdbc:mysql://localhost/mmwy_blog\
    ?????????????????????????????useUnicode
    =true\
    ????????????????????????????&characterEncoding
    =utf-8
    如果設成iso-8859-1、utf-8,保存一點問題都沒有,換用gbk、gb2312、big5之類的字符集,問題就出來了。

    posted @ 2006-10-12 15:54 mmwy 閱讀(1767) | 評論 (1)編輯 收藏

    最近開始嘗試hibernate annotations,終于成功的將手上一個小應用轉為annotations :)

    1、spring orm support
    與原來使用LocalSessionFactoryBean相比,變動不大(AnnotationSessionFactoryBean本來就是從LocalSessionFactoryBean類繼承過來的嘛)
    ?1????<bean
    ?2?????????id="sessionFactory"
    ?3?????????class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
    ?4?????????parent="AbstractSessionFactory">
    ?5?????????<property?name="annotatedClasses">
    ?6?????????????<list>
    ?7?????????????????<value>xxx.xxx.xxx.domain.Account</value>
    ?8?????????????</list>
    ?9?????????</property>
    10?????</bean>
    11?????<bean
    12?????????id="AbstractSessionFactory"
    13?????????class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
    14?????????abstract="true">
    15?????????<property
    16?????????????name="dataSource"
    17?????????????ref="DataSource"?/>
    18?????????<property?name="hibernateProperties">
    19?????????????<props>
    20?????????????????<prop?key="hibernate.dialect">${hibernate.dialect}</prop>
    21?????????????????<prop?key="hibernate.show_sql">${hibernate.show_sql}</prop>
    22?????????????????<prop?key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
    23?????????????????<prop?key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
    24?????????????????<prop?key="hibernate.cache.provider_class">${hibernate.cache.provider_class}</prop>
    25?????????????</props>
    26?????????</property>
    27?????????<property
    28?????????????name="lobHandler"
    29?????????????ref="DefaultLobHandler"?/>
    30?????</bean>
    2、id的配置
    非常簡單,在id的getter上面加個“@Id”就可以了。此時采用的id策略是javax.persistence.GenerationType.AUTO,也可以再加上“@GeneratedValue(generator =GenerationType.IDENTITY|GenerationType.SEQUENCE|GenerationType.TABLE)”換成其它策略。
    我的應用采用的是hibernate的uuid策略,就不得不在這兒使用hibernate的擴展了
    ??@Id
    ??@Column(length?
    =?32)
    ??@GeneratedValue(generator?
    =?"system-uuid")
    ??@GenericGenerator(name?
    =?"system-uuid",?strategy?=?"uuid")

    3、級聯策略
    在ejb3-persistence.jar中只定義了ALL、MERGE、PERSIST、REFRESH、REMOVE,比較惡心的就是,刪除對象的時候,并不會級聯刪除關聯對象,而是用update xx set parent_id=null where parent_id=?這類語句把關系干掉了事。不得已,在這兒用了hibernate的DELETE_ORPHAN。
    ??@OneToMany(targetEntity?=?Attachment.class)
    ??@Cascade(value?
    =?{org.hibernate.annotations.CascadeType.DELETE_ORPHAN,
    ??????org.hibernate.annotations.CascadeType.ALL})
    ??@JoinColumn(name?
    =?"info_id")
    4、CACHE
    ejb3-persistence.jar里面沒有找到cache的配置,繼續請出hibernate來干活
    import?org.hibernate.annotations.Cache;
    import?org.hibernate.annotations.CacheConcurrencyStrategy;

    @Entity
    @Table(name?
    =?"T_INFO")
    @Cache(usage?
    =?CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
    5、自定義字段類型
    我的POJO中有一個private String content;的屬性,按ejb3配成@Lob后,被處理成了text類型,text 64k的存儲容量還是比較可憐了。
    ??@Lob
    ??@Column(columnDefinition?
    =?"LongText")

    posted @ 2006-10-12 15:38 mmwy 閱讀(4887) | 評論 (0)編輯 收藏

    以如下字符串為例:
    <h1>AVG?Internet?Security?full?license?free?of?charge!</h1>
    <p>GRISOFT
    ,?the?supplier?of?AVG?security?software,?has?released?the?Public?Beta?2?version?of?the?upcoming?AVG?7.5?edition.?Individual?programs?are?now?available?for?testing?purposes?to?everyone.?Why?not?participate?in?our?AVG?beta?testing,?complete?the?questionnaire?about?testing?AVG?7.5?and?get?a?free?license??We?will?draw?100?participants?from?all?of?the?received?feedback?forms.?Winners?will?obtain?a?two-year?license?for?AVG?Internet?Security?7.5?completely?free?of?charge.</p>
    使用RichTextEditor進行編輯時,產生的html有oFCKeditor_InfoEdit_model_content.Value = 'xxx'字樣,由于字符串中包含單引號、雙引號、換行符等字符,編輯器無法進行處理,瀏覽器控制臺報js錯誤。

    在freemarker中提供了一個StringUtil工具,在使用RichTextEditor前,應使用StringUtil.javaStringEnc()進行預處理。
    posted @ 2006-09-25 12:05 mmwy 閱讀(829) | 評論 (1)編輯 收藏

    用webwork 2.2.4、sitemesh 2.2.1、freemarker 2.3.8,操作系統為winxp pro sp2.

    web.xml配置大致如下:

    ?1 ???? < filter >
    ?2 ???????? < filter-name > encodingFilter </ filter-name >
    ?3 ???????? < filter-class > com.yninfo.rules.web.util.CharacterEncodingFilter </ filter-class >
    ?4 ???????? < init-param >
    ?5 ???????????? < param-name > encoding </ param-name >
    ?6 ???????????? < param-value > UTF-8 </ param-value >
    ?7 ???????? </ init-param >
    ?8 ???????? < init-param >
    ?9 ???????????? < param-name > forceEncoding </ param-name >
    10 ???????????? < param-value > true </ param-value >
    11 ???????? </ init-param >
    12 ???? </ filter >
    13 ???? < filter >
    14 ???????? < filter-name > webwork-cleanup </ filter-name >
    15 ???????? < filter-class > com.opensymphony.webwork.dispatcher.ActionContextCleanUp </ filter-class >
    16 ???? </ filter >
    17 ???? < filter >
    18 ???????? < filter-name > sitemesh </ filter-name >
    19 ???????? < filter-class > com.opensymphony.webwork.sitemesh.FreeMarkerPageFilter </ filter-class >
    20 ???? </ filter >
    21 ???? < filter >
    22 ???????? < filter-name > webwork </ filter-name >
    23 ???????? < filter-class > com.opensymphony.webwork.dispatcher.FilterDispatcher </ filter-class >
    24 ???? </ filter >
    25 ???? < filter-mapping >
    26 ???????? < filter-name > webwork-cleanup </ filter-name >
    27 ???????? < url-pattern > *.ftl </ url-pattern >
    28 ???? </ filter-mapping >
    29 ???? < filter-mapping >
    30 ???????? < filter-name > sitemesh </ filter-name >
    31 ???????? < url-pattern > *.ftl </ url-pattern >
    32 ???? </ filter-mapping >
    33 ???? < filter-mapping >
    34 ???????? < filter-name > encodingFilter </ filter-name >
    35 ???????? < url-pattern > *.ftl </ url-pattern >
    36 ???? </ filter-mapping >
    37 ???? < filter-mapping >
    38 ???????? < filter-name > webwork </ filter-name >
    39 ???????? < url-pattern > *.ftl </ url-pattern >
    40 ???? </ filter-mapping >
    41 ???? < filter-mapping >
    42 ???????? < filter-name > webwork </ filter-name >
    43 ???????? < url-pattern > /webwork/* </ url-pattern >
    44 ???? </ filter-mapping >

    xwork.xml配置如下:
    1????????<action
    2????????????name="index"
    3????????????class="com.opensymphony.xwork.ActionSupport">
    4????????????<result
    5????????????????name="success"
    6????????????????type="freemarker">
    7????????????????<param?name="location">/admin/index.ftl</param>
    8????????????</result>
    9????????</action>
    sitemesh 配置如下
    1????<decorator
    2????????name="admin"
    3????????page="/admin/main.ftl">
    4????????<pattern>/admin/*.ftl</pattern>
    5????</decorator>

    在tomcat 5.1.17、resin 3.0.19上跑得順順利利的,一移到weblogic 8.1.5上就報錯
    ?1####<2006-9-8?上午02時46分44秒?CST>?<Error>?<HTTP>?<www-c1f900a12b2>?<myserver>?<ExecuteThread:?'14'?for?queue:?'weblogic.kernel.Default'>?<<WLS?Kernel>>?<>?<BEA-101104>?<Servlet?execution?in?servlet?context?"ServletContext(id=2664121,name=rules,context-path=/rules)"?failed,?java.net.ProtocolException:?Didn't?meet?stated?Content-Length,?wrote:?'4949'?bytes?instead?of?stated:?'4763'?bytes..
    ?2java.net.ProtocolException:?Didn't?meet?stated?Content-Length,?wrote:?'4949'?bytes?instead?of?stated:?'4763'?bytes.
    ?3????at?weblogic.servlet.internal.ServletOutputStreamImpl.ensureContentLength()V(ServletOutputStreamImpl.java:481)
    ?4????at?weblogic.servlet.internal.ServletResponseImpl.ensureContentLength()V(ServletResponseImpl.java:1253)
    ?5????at?weblogic.servlet.internal.ServletResponseImpl.send()V(ServletResponseImpl.java:1265)
    ?6????at?weblogic.servlet.internal.ServletRequestImpl.execute(Lweblogic/kernel/ExecuteThread;)V(ServletRequestImpl.java:2771)
    ?7????at?weblogic.kernel.ExecuteThread.execute(Lweblogic/kernel/ExecuteRequest;)V(ExecuteThread.java:224)
    ?8????at?weblogic.kernel.ExecuteThread.run()V(ExecuteThread.java:183)
    ?9????at?java.lang.Thread.startThreadFromVM(Ljava/lang/Thread;)V(Unknown?Source)
    10>?

    折騰了好幾天,各種方式試過,最后還是從sitemesh cvs上下了最新的源碼重新編譯解決問題。
    posted @ 2006-09-13 17:52 mmwy 閱讀(1955) | 評論 (1)編輯 收藏

    感謝google,感謝"webwork2.2.2的富文本編輯器的不完美解決方法"一文,感謝李李。當然,最應該感謝的是開源(刨源代碼刨出來的)。

    1、解決/webwork/*的路徑問題
    解決辦法見“http://www.tkk7.com/mmwy/archive/2006/08/18/64234.html
    BTW:也可以象“不完美解決方法”一文中描述的一樣,設webwork.serve.static=false,將static/下的東西拷至/webwork目錄下。

    2、重寫(繼承)DefaultRichtexteditorConnector類,解決無法在windows平臺上創建目錄的問題

    ?1 public ? class ?RichtexteditorConnector? extends ?DefaultRichtexteditorConnector? {
    ?2 ?? /**
    ?3 ???*?解決無法在windows平臺上創建目錄的問題
    ?4 ???*?overriding?methods
    ?5 ???*?(non-Javadoc)
    ?6 ???*? @see ?com.opensymphony.webwork.components.DefaultRichtexteditorConnector#calculateActualServerPath(java.lang.String,?java.lang.String,?java.lang.String)
    ?7 ??? */

    ?8 ?? protected ?String?calculateActualServerPath(String?actualServerPath,
    ?9 ??????String?type,?String?folderPath)? throws ?Exception? {
    10 ????String?path? = ?StringUtils.replaceChars( " file:/// "
    11 ???????? + ?servletContext.getRealPath( " / " ? + ?actualServerPath),? ' \\ ' ,? ' / ' );
    12 ????makeDirIfNotExists(path);
    13 ????path? = ?path.endsWith( " / " )
    14 ?????? ? ?path
    15 ??????:?path? + ? " / " ;
    16 ???? return ?path? + ?type? + ?folderPath;
    17 ??}

    18
    19 ?? private ?ServletContext?servletContext;
    20
    21 ?? public ? void ?setServletContext(ServletContext?servletContext)? {
    22 ???? this .servletContext? = ?servletContext;
    23 ??}

    24 }

    3、配置webwork.xml,解決上傳路徑自定義問題(actualServerPath參數,默認的使用DefaultRichtexteditorConnector類中protected String _actualServerPath = "/com/opensymphony/webwork/static/richtexteditor/data/";的定義),解決獲取上傳文件url路徑問題(默認的使用AbstractRichtexteditorConnector類中String _serverPath = "/webwork/richtexteditor/data/";的定義)

    ?1 ???? < package
    ?2 ???????? name ="richtexteditor-browse"
    ?3 ????????extends ="webwork-default"
    ?4 ????????namespace ="/webwork/richtexteditor/editor/filemanager/browser/default/connectors/jsp" >
    ?5 ???????? < action
    ?6 ???????????? name ="connector"
    ?7 ????????????class ="com.mmwy.weblogic_sitemesh.util.RichtexteditorConnector"
    ?8 ????????????method ="browse" >
    ?9 ???????????? < result
    10 ???????????????? name ="getFolders"
    11 ????????????????type ="richtexteditorGetFolders" ? />
    12 ???????????? < result
    13 ???????????????? name ="getFoldersAndFiles"
    14 ????????????????type ="richtexteditorGetFoldersAndFiles" ? />
    15 ???????????? < result
    16 ???????????????? name ="createFolder"
    17 ????????????????type ="richtexteditorCreateFolder" ? />
    18 ???????????? < result
    19 ???????????????? name ="fileUpload"
    20 ????????????????type ="richtexteditorFileUpload" ? />
    21 ???????????? < param? name ="actualServerPath" > /upload/ </ param >
    22 ???????????? < param? name ="serverPath" > /upload/ </ param >
    23 ???????? </ action >
    24 ???? </ package >
    25
    26 ???? < package
    27 ???????? name ="richtexteditor-upload"
    28 ????????extends ="webwork-default"
    29 ????????namespace ="/webwork/richtexteditor/editor/filemanager/upload" >
    30 ???????? < action
    31 ???????????? name ="uploader"
    32 ????????????class ="com.mmwy.weblogic_sitemesh.util.RichtexteditorConnector"
    33 ????????????method ="upload" >
    34 ???????????? < result? name ="richtexteditorFileUpload" ? />
    35 ???????????? < param? name ="actualServerPath" > /upload/ </ param >
    36 ???????????? < param? name ="serverPath" > /upload/ </ param >
    37 ???????? </ action >
    38 ???? </ package >

    注意:serverPath路徑必須有后面的"/"。

    4、解決獲取上傳文件url只能使用80端口的問題
    順著源碼一直跟進,首先是DefaultRichtexteditorConnector類:

    1 ???? protected ?String?calculateServerPath(String?serverPath,?String?folderPath,?String?type)? throws ?Exception? {
    2 ???????? // return?UrlHelper.buildUrl(serverPath,?_request,?_response,?null,?_request.getScheme(),?true,?true,?true);
    3 ???????? return ?UrlHelper.buildUrl(serverPath + type + folderPath,?_request,?_response,? new ?HashMap(),?_request.getScheme(),? true ,? true ,? true );
    4 ????}

    再跟進UrlHelper.buildUrl方法

    ?1 ???? public ? static ?String?buildUrl(String?action,?HttpServletRequest?request,?HttpServletResponse?response,?Map?params,?String?scheme,? boolean ?includeContext,? boolean ?encodeResult,? boolean ?forceAddSchemeHostAndPort)? {
    ?2 ????????StringBuffer?link? = ? new ?StringBuffer();
    ?3
    ?4 ???????? boolean ?changedScheme? = ? false ;
    ?5
    ?6 ???????? int ?httpPort? = ?DEFAULT_HTTP_PORT;
    ?7
    ?8 ???????? try ? {
    ?9 ????????????httpPort? = ?Integer.parseInt((String)?Configuration.get(WebWorkConstants.WEBWORK_URL_HTTP_PORT));
    10 ????????}
    ? catch ?(Exception?ex)? {
    11 ????????}

    12
    13 ???????? int ?httpsPort? = ?DEFAULT_HTTPS_PORT;
    14
    15 ???????? try ? {
    16 ????????????httpsPort? = ?Integer.parseInt((String)?Configuration.get(WebWorkConstants.WEBWORK_URL_HTTPS_PORT));
    17 ????????}
    ? catch ?(Exception?ex)? {
    18 ????????}

    19

    因此,解決這個問題的方法很簡單,只要在webwork.properties中設webwork.url.http.port = 8080即可。

    5、語言問題
    RichTextEditor標記autoDetectLanguage默認值為true,在中文環境下使用/editor/lang/zh.js,顯示繁體中文字符,而簡體中文應該使用zh-cn.js,因此,應設置defaultLanguage="zh-cn"。

    1 ???????????? < @ww .richtexteditor
    2 ????????????????theme ="simple"
    3 ????????????????defaultLanguage ="zh-cn"
    4 ????????????????width ="750"
    5 ????????????????height ="500"
    6 ????????????????name ="description4" ? />

    ?



    ?

    posted @ 2006-09-11 12:29 mmwy 閱讀(2275) | 評論 (0)編輯 收藏

    在網上google半天也沒見人解決,還是看了FilterDispatcher的源碼才解決,特地貼到blog上,備忘吧。


    在com.opensymphony.webwork.dispatcher.FilterDispatcher中有以下代碼
    1?????????????if?("true".equals(Configuration.get(WebWorkConstants.WEBWORK_SERVE_STATIC_CONTENT))?
    2?????????????????????&&?resourcePath.startsWith("/webwork"))?{
    3?????????????????String?name?=?resourcePath.substring("/webwork".length());
    4?????????????????findStaticResource(name,?response);
    5?????????????}?else?{
    6?????????????????//?this?is?a?normal?request,?let?it?pass?through
    7?????????????????chain.doFilter(request,?response);
    8?????????????}
    也就是說,只要webwork.properties文件中webwork.serve.static=true(系統默認),并且FilterDispatcher這個過濾器對/webwork/*這個url進行了處理的話,就不會發生使用ww2提供的datepicker時,找不到/webwork/*下所有的js、image等資源,不得不手工拷貝webwork.jar中/com/opensymphony/webwork/static為/webwork/*的情況。
    ?1?????<filter>
    ?2?????????<filter-name>webwork</filter-name>
    ?3?????????<filter-class>com.opensymphony.webwork.dispatcher.FilterDispatcher</filter-class>
    ?4?????</filter>
    ?5?????<filter-mapping>
    ?6?????????<filter-name>webwork</filter-name>
    ?7?????????<url-pattern>*.action</url-pattern>
    ?8?????</filter-mapping>
    ?9?????<filter-mapping>
    10?????????<filter-name>webwork</filter-name>
    11?????????<url-pattern>/webwork/*</url-pattern>
    12?????</filter-mapping>

    posted @ 2006-08-18 02:16 mmwy 閱讀(1550) | 評論 (2)編輯 收藏

    很簡單,就幾個jar包

    1 groovy-all- 1.0 -jsr- 05 .jar
    2 groovysoap-all- 20060503 .jar
    3 activation.jar
    4 log4j- 1.2.13 .jar
    5 mail.jar

    拿以前HelloXfire時的Echo接口做測試,代碼少得可憐

    ?1 import ?groovy.net.soap.SoapClient
    ?2
    ?3 class ?HelloGroovy? {
    ?4
    ?5 ?? static ? void ?main(args)? {
    ?6 ????def?proxy? = ? new ?SoapClient( " http://localhost:8080/query/EchoService?wsdl " );
    ?7 ????System.out.println(proxy.sayHello());?????
    ?8 ??}

    ?9
    10 }

    在Eclipse里面寫完,一運行,出來個“HelloWorld”,順利得讓我簡直不敢相信。
    posted @ 2006-05-06 12:41 mmwy 閱讀(590) | 評論 (1)編輯 收藏

    受白衣同志的當,上了xfire的賊船,拋棄了axis,嗚!

    xfire 1.0終于final了,試用了一下,,感覺同1.0M6相比,使用變化不大。

    看看user guide,照著examples下的例子,基本上hello xfire不成問題。

    1、jar包

    同以往一樣,xfire user guide中的Dependency Guide.html還是說得不明不白,除了讓人發暈,沒有太大的實際意義。

    SNAG-0000.jpg

    注:
    1)XmlSchema-1.0.jar、jakatra commons httpclient/codec只有在Dynamic Client中才需要用。
    2)采用quick start、examples/book中用的service.xml配置方法時,xbean-spring與spring有兼容問題,我用1.2.7、2.0M2的spring時,總是報addPropertyValue(String,Object)之類的異常,換成1.2.6以后一切正常。用examples/spring例子中的配置方法時,沒有出現這種情況。

    2、quick start、examples/book

    這種做法很簡單,好象也不太合我的胃口,就沒仔細折騰。
    (1)在web.xml中配置一下

     1  <servlet>
     2    <servlet-name>XFireServlet</servlet-name>
     3    <display-name>XFire Servlet</display-name>
     4    <servlet-class>org.codehaus.xfire.transport.http.XFireConfigurableServlet</servlet-class>
     5  </servlet>
     6
     7  <servlet-mapping>
     8    <servlet-name>XFireServlet</servlet-name>
     9    <url-pattern>/servlet/XFireServlet/*</url-pattern>
    10  </servlet-mapping>
    11
    12  <servlet-mapping>
    13    <servlet-name>XFireServlet</servlet-name>
    14    <url-pattern>/services/*</url-pattern>
    15  </servlet-mapping>

    (2)編碼。這個不用說,呵呵
    (3)在classpath中,建META-INF/xfire/services.xml配置文件,把剛才做好的webservices配置一下。

    1<beans xmlns="http://xfire.codehaus.org/config/1.0">
    2  <service>
    3    <name>BookService</name>
    4    <namespace>http://xfire.codehaus.org/BookService</namespace>
    5    <serviceClass>org.codehaus.xfire.demo.BookService</serviceClass>
    6  </service>
    7</beans>

    (4)然后就是deploy,訪問http://ip:port/webapp name/BookService?WSDL之類的動作了。

    3、examples/spring

    xfire和spring勾搭得比較緊密啊,只需要簡單配置一下,就可以把spring.xml中配置好的bean拿出來做web services了。
    (1)折騰spring的東西(略)。
    (2)在web.xml中配置一下(注意xfire那一段)

     1    <context-param>
     2        <param-name>contextConfigLocation</param-name>
     3        <param-value>/WEB-INF/applicationContext.xml classpath:org/codehaus/xfire/spring/xfire.xml</param-value>
     4    </context-param>
     5
     6    <listener>
     7        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
     8    </listener>
     9
    10    <servlet>
    11        <servlet-name>xfire</servlet-name>
    12        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    13    </servlet>
    14    <servlet-mapping>
    15        <servlet-name>xfire</servlet-name>
    16        <url-pattern>/*</url-pattern>
    17    </servlet-mapping>

    (3)在WEB-INF/xfire-servlet.xml中把spring bean同xfire webservices“關聯”起來。這個xfire-servlet.xml實際上就是一個標準的spring.xml配置文件。

     1<?xml version="1.0" encoding="UTF-8"?>
     2<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
     3<beans>
     4    <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
     5        <property name="urlMap">
     6            <map>
     7                <entry key="/EchoService" value-ref="echo"/>
     8            </map>
     9        </property>
    10    </bean>
    11    
    12    <bean id="echo" class="org.codehaus.xfire.spring.remoting.XFireExporter">
    13        <property name="serviceFactory" ref="xfire.serviceFactory"/>
    14        <property name="xfire" ref="xfire"/>
    15        <property name="serviceBean" ref="echoBean"/>
    16        <property name="serviceClass" value="org.codehaus.xfire.spring.example.Echo"/>>
    17    </bean>
    18</beans>

    注:第16行,xfire 1.0M6中用serviceInterface,現在改成serviceClass了。

    (4)然后就完工,用http://ip:port/webapp name/xfire/EchoService?WSDL可以看到WSDL內容。

    4、客戶端

    按我的惡習,這類事情,肯定是直接開vs.net或者C# developer來顯擺一下了。不得不承認,.net里面調web services就是方便啊!
    SNAG-0001.jpg
    至于java做client么,以前一般是用axis來生成client class,xfire也提供類似的工具,不過對于xfire來說,最簡單的辦法就是用Dynamic Client,幾行代碼搞定。

    1    Service serviceModel = new ObjectServiceFactory().create(Echo.class);
    2    Echo service = (Echo) new XFireProxyFactory().create(serviceModel,
    3        "http://localhost:8080/xfire-examples/EchoService");
    4    String result = service.echo("ok");


     

    posted @ 2006-03-02 10:47 mmwy 閱讀(11113) | 評論 (13)編輯 收藏

    首先強烈遣責water ye同學不負責任的行為,那家伙在blog上貼了一段spring 2.0m2的test代碼就了事,居然不測試一下,結果俺的spring groovy test代碼折騰半天才過去。

    測試代碼俺就不貼了,spring的配置就夠了
     1 <?xml version="1.0" encoding="GBK"?>
     2 <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" 
     3     "http://www.springframework.org/dtd/spring-beans.dtd">
     4 <beans>
     5     <bean class="org.springframework.scripting.support.ScriptFactoryPostProcessor" />
     6     <bean id="inlineMessenger" class="org.springframework.scripting.groovy.GroovyScriptFactory">
     7         <constructor-arg>
     8             <value>inline:
     9                     package spring.groovy;
    10                     
    11                     class GroovyInlineMessenger  implements Messenger{
    12                         void sayHello(){
    13                             System.err.println("Hello");
    14                         }
    15                     }
    16             </value>
    17         </constructor-arg>
    18     </bean>
    19     <bean id="messenger" class="org.springframework.scripting.groovy.GroovyScriptFactory">
    20         <constructor-arg value="classpath:spring/groovy/GroovyMessenger.groovy" />
    21         <property name="message" value="Hello World!" />
    22     </bean>
    23 </beans>

    1、第5行的bean定義一定要有,估計是提前編譯groovy腳本的(具體的可能啃一下源碼就明白了)。
    2、inlineMessenger這個bean的定義,inline一定要緊跟著<value>寫,我為了美觀,弄成下面兩種寫法都沒過去。
     1     <bean id="inlineMessenger" class="org.springframework.scripting.groovy.GroovyScriptFactory">
     2         <constructor-arg>
     3             <value>
     4             inline:
     5                     package spring.groovy;
     6                     
     7                     class GroovyInlineMessenger  implements Messenger{
     8                         void sayHello(){
     9                             System.err.println("Hello");
    10                         }
    11                     }
    12             </value>
    13         </constructor-arg>
    14     </bean>
    1     <bean id="inlineMessenger" class="org.springframework.scripting.groovy.GroovyScriptFactory">
     2         <constructor-arg>
     3             <value>
     4             <![CDATA[inline:
     5                     package spring.groovy;
     6                     
     7                     class GroovyInlineMessenger  implements Messenger{
     8                         void sayHello(){
     9                             System.err.println("Hello");
    10                         }
    11                     }]]>
    12             </value>
    13         </constructor-arg>
    14     </bean>
    寫成這樣倒是過的
     1     <bean id="inlineMessenger" class="org.springframework.scripting.groovy.GroovyScriptFactory">
     2         <constructor-arg>
     3             <value><![CDATA[inline:
     4                     package spring.groovy;
     5                     
     6                     class GroovyInlineMessenger  implements Messenger{
     7                         void sayHello(){
     8                             System.err.println("Hello");
     9                         }
    10                     }]]>
    11             </value>
    12         </constructor-arg>
    13     </bean>
    俺平時習慣讓myeclipse對xml進行格式化,照這么看來,估計一不小心,按個ctrl+shift+F,好端端的spring groovy代碼就過不去了,然后就慢慢找問題吧。

    posted @ 2006-02-07 10:09 mmwy 閱讀(942) | 評論 (0)編輯 收藏

    主站蜘蛛池模板: 亚洲欧洲免费视频| h片在线免费观看| 国产成人精品日本亚洲11| 亚洲综合伊人久久综合| 麻豆国产人免费人成免费视频| 91免费国产精品| 中文字幕无码播放免费| 中文字幕无线码中文字幕免费| 国内成人精品亚洲日本语音| 亚洲一区二区三区不卡在线播放| 亚洲视频精品在线| 精品亚洲永久免费精品| 亚洲人成电影网站国产精品 | 亚洲综合一区二区精品导航| 亚洲一本大道无码av天堂| 日韩视频免费一区二区三区| 成年丰满熟妇午夜免费视频| 精品香蕉在线观看免费| **俄罗斯毛片免费| 91久久精品国产免费一区| a毛片免费全部播放完整成| 一个人免费观看日本www视频| 国产精品亚洲综合天堂夜夜| 亚洲精品无码久久久久牙蜜区| 亚洲妇女熟BBW| 亚洲色精品三区二区一区| 亚洲精品第一国产综合野| 亚洲日韩在线视频| 国产高清在线免费| 在线成人a毛片免费播放| 好男人视频在线观看免费看片| 无码中文字幕av免费放| 免费无码又爽又刺激聊天APP| 欧美最猛性xxxxx免费| 美女被cao免费看在线看网站| a拍拍男女免费看全片| 一级女人18毛片免费| 国拍在线精品视频免费观看| 国产福利在线观看免费第一福利| 免费看国产精品3a黄的视频| 免费无码黄动漫在线观看|