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

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

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

    隨筆-34  評論-1965  文章-0  trackbacks-0

    很久沒有更新BLOG了,前一段時間公司的項目比較忙,另外我還和一位出版社的朋友談寫書的事情,所以一直沒有時間,完成《Struts 2與AJAX》。后來寫書的事情吹了,趁今天有點空閑就把它完成。

    在大家看這部分文章之前,我想對于寫書的事情說兩句,或者應該叫發牢騷才對。通過這次寫書失敗的經歷,我明白為什么國內的IT書籍多數是濫于充數、粗制濫造、缺乏經典。其實說白了就是一個“錢”字作怪。為了市場,很多編輯可能會“建議”你去“抄考”一些國內相對暢銷的同類書籍,例如寫Struts就一定要按所謂的MVC進行目錄分類,美其名曰“容易入門”。我認為“MVC”的概念雖然重要,但對初學者而言,需要對編程有一定的了解才容易明白此概念。另外,為了“實用”,不惜使用相同的技術重復編寫不同的范例。可能是我不太了解讀者的心理吧。

    言歸正傳,在上兩部分的《Struts 2與AJAX》中我介紹了Struts 2與DOJO結合實現AJAX的知識,本文將介紹在Struts 2中使用DWR實現AJAX表單校驗。

    什么是DWR

    DWR(Direct Web Remoting)是在Java EE中較流行的AJAX框架,它的最大優勢就是可以像使用本地的Javascript函數一樣,調用服務器上的Java方法。如下圖所示:

    DWR工作原理
    圖1 DWR工作原理

    其實DWR原理也不復雜,它先在web.xml中配置一個Servlet,映射到特定的路徑(通常是%CONTEXT_PATH%/dwr/*)。這個Servlet的作用就是初始化要暴露給Javascript調用的Java類(通過dwr.xml進行配置),并生成相應的代理的Javascript類代碼。在XHR請求到來的時候,Servlet負責將請求的參數變成對應的Java對象,并以其為參數調用目標Java方法,并將返回值轉化為Javascript代碼。詳情請參考:http://getahead.ltd.uk/dwr/

    Struts 2與DWR

    在Struts 2.0.x中使用DWR實現AJAX表單校驗。在大家掌握了DWR的原理后,下面我想詳細介紹一下實現的步驟。

    首先,到以下站點https://dwr.dev.java.net/files/documents/2427/47455/dwr.jar下載DWR的1.1.4版本的JAR包。需要注意的是,DWR雖然已經發布2.0版本,但它與1.1.4有很大的區別,所以請大家不要使用2.0版本,否則會出現異常的;

    接著,新建WEB工程,將下圖所示的JAR包加入到工程的“Build Path”中;

    依賴的JAR包
    圖2 依賴的JAR包

    接下來,配置web.xml文件,內容如下:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="WebApp_9" 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">

       
    <display-name>Struts 2 AJAX Part 3</display-name>

       
    <filter>
           
    <filter-name>struts-cleanup</filter-name>
           
    <filter-class>
                org.apache.struts2.dispatcher.ActionContextCleanUp
           
    </filter-class>
       
    </filter>

       
    <filter-mapping>
           
    <filter-name>struts-cleanup</filter-name>
           
    <url-pattern>/*</url-pattern>
       
    </filter-mapping>

       
    <filter>
           
    <filter-name>struts2</filter-name>
           
    <filter-class>
                org.apache.struts2.dispatcher.FilterDispatcher
           
    </filter-class>
       
    </filter>

       
    <filter-mapping>
           
    <filter-name>struts2</filter-name>
           
    <url-pattern>/*</url-pattern>
       
    </filter-mapping>
       
    <!-- 開始DWR配置 -->
       
    <servlet>
           
    <servlet-name>dwr</servlet-name>
           
    <servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class>
           
    <init-param>
               
    <param-name>debug</param-name>
               
    <param-value>true</param-value>
           
    </init-param>
       
    </servlet>

       
    <servlet-mapping>
           
    <servlet-name>dwr</servlet-name>
           
    <url-pattern>/dwr/*</url-pattern>
       
    </servlet-mapping>
       
    <!-- 結束DWR配置 -->
       
    <welcome-file-list>
           
    <welcome-file>index.html</welcome-file>
       
    </welcome-file-list>

    </web-app>
    清單1 WebContent/WEB-INF/web.xml

    然后是DWR的配置文件:

    <?xml version="1.0" encoding="UTF-8"?>

    <!-- START SNIPPET: dwr -->
    <!DOCTYPE dwr PUBLIC 
        "-//GetAhead Limited//DTD Direct Web Remoting 1.0//EN" 
        "http://www.getahead.ltd.uk/dwr/dwr10.dtd"
    >

    <dwr>
       
    <allow>
           
    <create creator="new" javascript="validator">
               
    <param name="class" value="org.apache.struts2.validators.DWRValidator"/>
           
    </create>
           
    <convert converter="bean" match="com.opensymphony.xwork2.ValidationAwareSupport"/>
       
    </allow>

       
    <signatures>
           
    <![CDATA[
            import java.util.Map;
            import org.apache.struts2.validators.DWRValidator;

            DWRValidator.doPost(String, String, Map<String, String>);
           
    ]]>
       
    </signatures>
    </dwr>
    <!-- END SNIPPET: dwr -->
    清單2 WebContent/WEB-INF/dwr.xml

    通過以上配置,我們可以將DWRValidator中的方法暴露為Javascript可以調用的遠程接口。

    在正確完成以上步驟之后,我們發布運行一下應用程序,在瀏覽器地址欄中輸入http://localhost:8080/Struts2_Ajax3/dwr/,應該會出現如下頁面:

    DWR Servlet默認輸出頁面
    圖3 DWR Servlet默認輸出頁面

     接下來,我們要開始編寫Action類了,代碼如下:

    package tutorial;

    import com.opensymphony.xwork2.ActionSupport;

    public class AjaxValidation extends ActionSupport {
       
    private static final long serialVersionUID = -7901311649275887920L;

       
    private String name;
       
    private String password;
       
    private int age;
       
       
    public int getAge() {
           
    return age;
       }

       
       
    public void setAge(int age) {
           
    this.age = age;
       }

       
       
    public String getName() {
           
    return name;
       }

       
       
    public void setName(String name) {
           
    this.name = name;
       }

       
       
    public String getPassword() {
           
    return password;
       }

       
       
    public void setPassword(String password) {
           
    this.password = password;
       }

       
       @Override
       
    public String execute() {        
           
    return SUCCESS;
       }

    }
    清單3 src/tutorial/AjaxValidation.java

    上述代碼一目了然,相信大家已經很熟悉了。下面,我們再來看看表單校驗的配置代碼:

    <!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN" "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
    <validators>
       
    <validator type="regex">
           
    <param name="fieldName">password</param>
           
    <param name="expression">
               
    <![CDATA[(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{8,10})$]]>
           
    </param>
           
    <message>Password must be between 8 and 10 characters, contain at least one digit and one alphabetic character, and must not contain special characters</message>
       
    </validator>    
       
    <field name="name">
           
    <field-validator type="requiredstring">
               
    <message>You must enter a name</message>
           
    </field-validator>
       
    </field>
       
    <field name="age">
           
    <field-validator type="int">
               
    <param name="min">18</param>
               
    <param name="max">127</param>
               
    <message>Age must be between 18 and 127</message>
           
    </field-validator>
       
    </field>
    </validators>
    清單4 src/tutorial/AjaxValidation-validation.xml

    對于AjaxValidation類的name、password和age三個字段,我分別用了非空、正規表達式和范圍驗證。正規表達式(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{8,10})$的作用是保證密碼由至少包括一個數字和一個字母,且不能含有符號的長度為8到10的字符串組成。它也是所謂強密碼(Strong Password)的普通實現。

    接下來的是JSP的代碼,內容如下:

    <%@ page language="java" contentType="text/html; charset=utf-8"
        pageEncoding
    ="utf-8"%>
    <%@ taglib prefix="s" uri="/struts-tags"%>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
       
    <head>
           
    <title>Struts 2 AJAX - Validation</title>
           
    <s:head theme="ajax" />
       
    </head>
       
    <body>
           
    <h2>
                AJAX Validation Using DWR
           
    </h2>
           
    <s:form method="post" validate="true" theme="ajax">
               
    <s:textfield label="Name" name="name" />
               
    <s:password label="Password" name="password" />
               
    <s:textfield label="Age" name="age" />
               
    <s:submit />
           
    </s:form>
       
    </body>
    </html>
    清單5 WebContent/AjaxValidation.jsp

    以上代碼也不復雜,不過需要的是注意的是除了要加入<s:head theme="ajax" />外,<s:form />也必須加入validate="true" theme="ajax"的屬性。

    最后是Struts 2的配置文件,內容如下所示:

    <?xml version="1.0" encoding="UTF-8"?>

    <!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
        "http://struts.apache.org/dtds/struts-2.0.dtd"
    >

    <struts>
       
    <package name="Struts2_AJAX_DEMO" extends="struts-default">
           
    <action name="AjaxValidation" class="tutorial.AjaxValidation">
               
    <result name="input">AjaxValidation.jsp</result>
               
    <result>AjaxValidation.jsp</result>
           
    </action>
       
    </package>
    </struts>
    清單6 src/struts.xml

    最后發布運應用程序,在瀏覽器地址欄中輸入http://localhost:8080/Struts2_Ajax3/AjaxValidation!input.action出現如下圖所示頁面:

    AjaxValidation頁面輸出
    圖4 AjaxValidation頁面輸出

    在文本框中輸入錯誤的值使頁面出現錯誤提示信息,如下圖所示:

    AjaxValidation頁面錯誤提示
    圖5 AjaxValidation頁面錯誤提示

    可能有朋友會問怎么知道這是通過AJAX進行校驗的呢?在這里我向大家推薦一個AJAX開發必備的工具——Firebug。Firebug是Firefox的一個功能強大的插件,它可以準確地輸出和定位Javascript的錯誤、通過直觀的方式查看HTML文檔的DOM及其樣式、所見即所得的編輯方式,更值得一贊的是它可以方便地對Javascript進行跟蹤和調試,如果你希望這進一步了解這個工具,請安裝Firefox 2.0以上版本,并使用它瀏覽以下網址http://www.getfirebug.com

    在安裝完成Firebug之后,在Firefox中打開http://localhost:8080/Struts2_Ajax3/AjaxValidation!input.action,按“F12”鍵找開Firebug窗口,如果你第一次使用Firebug,請點擊其窗口中的鏈接“Enable Firebug”激活插件。之后,點擊“Net”,并在出現的菜單中點擊選中“XHR”。然后將光標移入文本框,再將光標移出使文本框失去焦點,你可以看到Firebug窗口會多出一項記錄,如下圖所示:

    Firebug中查看XHR請求
    圖6 Firebug中查看XHR請求

    這就證明你在文本框失去焦出時,Struts 2會發送XHR請求到服務器以對該文本框值進行校驗。有興趣的朋友可以通過Firebug,研究XHR的請求與響應,這樣可以加深對DWR工作原理的理解。

    何時使用AJAX表單校驗

    雖然在Struts 2實現AJAX表單校驗是一件非常簡單的事,但我建議大家不要在所有的場合都使用這個功能,原因可以分為以下幾個方面:

    1. AJAX校驗在服務器上進行數據校驗,可能會比較耗時;
    2. AJAX校驗可能會過于頻繁,加重服務器的負載;
    3. 一些普通的校驗,只需要使用純Javascript便可以實現。

    讀到這里,有的朋友可能會問:“那么什么時候才應該使用AJAX表單校驗呢?”答案其實很簡單,當我們的校驗在頁面加載時還不能夠確定的情況下,就應該使用這個功能。例如,注冊用戶時,校驗用戶名是否已經存在;或者校驗涉及過多的頁務邏輯等。

    現在讓我們來改造一下上述例子,對于name我們可以使用AJAX校驗,但對于其它的字段應該使用純Javascript的校驗。

    在tutorial.AjaxValidation類加入如下方法:

       @Override
       
    public void validate() {
           Set
    <String> users = new HashSet<String>();
           users.add(
    "max");
           users.add(
    "scott");
           
    if(users.contains(name)) {
               addFieldError(
    "name", "The user name has been used!");
           }

       }
    清單7 src/tutorial/AjaxValidation.java代碼片段

    用于模擬用戶注冊的場境,當然在真實情況應該在數據庫中檢查用戶是否存在。

    接下來再修改JSP文件,將<s:form />里面的內容改為如下所示代碼:

            <s:form method="post" validate="true" theme="ajax_xhtml">
               
    <s:textfield label="Name" name="name" theme="ajax" />
               
    <s:password label="Password" name="password" theme="xhtml" />
               
    <s:textfield label="Age" name="age" theme="xhtml" />
               
    <s:submit theme="xhtml" />
           
    </s:form>
    清單8 WebContent/AjaxValidation.jsp代碼片段

    對比早前的JSP代碼,大家可以看出我將<s:form />的theme改成了“ajax_xhtml”,這個theme不是Struts 2自帶,需要自定義。另外,除了Name使用了ajax的theme之外,其它的表單標簽的theme都為xhtml,如此一來便可以實現只有當Name文本框失去焦點時才發生AJAX表單校驗。

    接下來,應該是我們的自定義ajax_xhtml的theme了。在源代碼文件夾下新建包“template.ajax_xhtml”,然后在其中加入form.ftl和form-close.ftl文件,內容分別如下:

    <#if parameters.validate?exists>
    <script type="text/javascript" src="${base}/struts/validationClient.js"></script>
    <script type="text/javascript" src="${base}/dwr/interface/validator.js"></script>
    <script type="text/javascript" src="${base}/dwr/engine.js"></script>
    <script type="text/javascript" src="${base}/struts/ajax/validation.js"></script>
    </#if>
    <#include "/${parameters.templateDir}/xhtml/form-validate.ftl" />
    <#include "/${parameters.templateDir}/simple/form.ftl" />
    <#include "/${parameters.templateDir}/xhtml/control.ftl" />
    清單9 src/template/ajax_xhtml/form.ftl

    上述的文件與xhtml theme中的form.ftl文件相似,我只是加入了AJAX表單校驗所用的Javascript庫,以便theme為ajax的表單標簽使用。

    <#include "/${parameters.templateDir}/xhtml/control-close.ftl" />
    <#include "/${parameters.templateDir}/simple/form-close.ftl" />
    <#include "/${parameters.templateDir}/xhtml/form-close-validate.ftl" />
    清單10 src/template/ajax_xhtml/form-close.ftl

    這個文件與xhtml theme中的form-close.ftl文件相同。

    最后發布運行應用程序,大家可以發現在Password與Age的校驗,只有在表單提交時才發生,而且是純Javascript的校驗。不過,以上代碼還不是很完善,在行為上有些BUG。

    總結

    Struts 2相比一些其它的框架,在實現AJAX方面的確簡單很多。更激動人心的是Struts 2的標簽庫支持基于模板的輸出,使得開發者可以跟據自身的需要方便地改變標簽的行為。

    在將要發布的Struts 2.1版本中,AJAX表單校驗將不再使用DWR,統一使用DOJO實現,詳情請參考:http://struts.apache.org/2.0.9/docs/ajax-validation.html

    posted on 2007-08-16 18:33 Max 閱讀(34176) 評論(76)  編輯  收藏 所屬分類: Struts 2.0系列

    評論:
    # re: Struts 2與AJAX(第三部分) 2007-08-16 19:46 | wsc
    Good!, Thanks for your share  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分)[未登錄] 2007-08-16 20:07 | 狒狒
    很好啊,看著你的文章做了一個小項目 呵呵 謝了  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2007-08-17 09:17 | fengyuan
    等得花兒都謝了!~  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2007-08-17 15:24 | liy
    好像DWR組件不是很穩定吧,有時會出現錯誤,不知道MAX大哥怎么看待這個問題  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2007-08-17 19:52 | SSong
    謝謝你這個系列的教程了  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2007-08-18 00:59 | plantegg
    樓主越來越專業,期待你的新文章好久了:)  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2007-08-18 01:01 | plantegg
    狗日的出書賺不了多少錢的(如果你花了很多精力去寫的話),印刷量又不大,Max看開了是好事啊,隨隨便便高點外快容易多了  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2007-08-21 22:24 | cuiy
    好,覺得你不錯!  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2007-08-22 13:51 | cleaner
    樓主,你真的很棒。
    就是最近一次有些慢了,害我每天都來看一看。  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2007-08-22 22:52 | Max
    @liy
    DWR的確給我們的AJAX開發帶來了很大的方便,不過如果需要開發一些比較大型的AJAX應用,最好也其它Javascript框架一起使用,如Prototype.js等。

    @plantegg
    寫書的話,可以更詳盡一點。不過,盡管不是寫書,我也最我的努力寫這個BLOG的。

    @cleaner
    對不起,最近比較忙;所以更新慢了下來。  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2007-08-23 16:57 | 牧碼人
    樓主,我強烈支持你的義舉,當然我也是受益者,頂!!!!!!!!!!  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2007-08-27 14:31 | pxcong
    當驗證成功后,怎樣實現跳轉的呢? 能幫我講講嗎?  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2007-08-31 15:19 | mark
    Max 公布一個銀行帳號吧!咱們不但在精神支持你,而且也要在經濟上支持你!  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2007-09-01 20:46 | welmen
    Thank you ,I'm just running for a project.you have done me a great favour!!  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2007-09-04 10:19 | Jarwang
    請問?????????max


    <s:iterator />
    如何排序????
    例:
    <s:iterator value="Orders"/>
    <s:propety value="orderName"/>
    <s:property value="orderPrices" />
    </s:iterator>

    在java類中用preparedStatement查詢數據庫
    例:select orderName,orderPrices from Orders order by orderName
    然后,寫入order類中.

    最后,給頁面調用.

    可問題是:::::::::::記錄沒有排序.....盡管用了 order by orderName?????

    tks!!!!!!!!!!!!!!!!!!!!!!!  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2007-09-05 00:06 | Max
    @mark
    謝謝您的支持。不過,我寫這個BLOG的目的不是為了錢。而且我覺得真正值得經濟支持的是Struts 2的項目的開發者,他們才是真正的英雄!  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2007-09-05 00:38 | Max
    # re: Struts 2與AJAX(第三部分) 2007-09-05 10:46 | jiew
    @wsc
    很感謝你這一系列教程 ,我剛看完,收獲很多 。謝了
    我會繼續關注你的BLOG的。  回復  更多評論
      
    # 問一個Struts2配置的問題 2007-09-06 21:26 | CG
    一 我的JSP的form.action,strute2Test 是工程的名稱
    form1.action="/strute2Test/login!sendMes.do"

    二 web.xml
    <filter>
    <filter-name>struts2</filter-name>
    <filter-class>
    org.apache.struts2.dispatcher.FilterDispatcher
    </filter-class>
    <init-param>
    <param-name>actionPackages</param-name>
    <param-value>com.test</param-value>
    </init-param>
    </filter>
    <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>*.do</url-pattern>
    </filter-mapping>

    三 我的Action
    package com.test;
    public class LoginAction extends ActionSupport {
    public String sendMes()
    {
    return "";
    }
    }

    我提交的時候,總是映射不到sendMes這個方法.錯誤:
    The requested resource (/strute2Test/com.test/login!sendMes.do) is not available.

    請問是怎么回事啊?  回復  更多評論
      
    # json plugin[未登錄] 2007-09-12 17:35 | Daniel
    Struts 2 JSON Plugin
    JSON Plugin
    這兩個插件有什么區別呀?有沒有JSON Plugin 的參考文檔或api呀在哪里呢?
    謝謝max大哥哥這么多好的文  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2007-09-13 00:17 | Max
    @Daniel
    應該是一樣的東西,
    至于文檔,請參考:http://cwiki.apache.org/S2PLUGINS/json-plugin.html  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2007-09-17 11:43 | javaEgg
    更激動人心的是Struts 2的標簽庫支持基于模板的輸出,使得開發者可以跟據自身的需要方便地改變標簽的行為。

    希望樓主下一期,就這個主題寫篇blog。
    期待中。。。  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分)[未登錄] 2007-09-18 13:19 | yingjie
    max兄,看了你的文章十分收益,有個問題想請教一下,就是把struts1.2的項目改成struts2.0,請問要注意哪些方面啊?還有就是action要怎么寫合適,沒有了ActionForm那么數據存放到action中要怎么存啊?總之就是有很多的問題要請教你,希望你能教我,我的郵箱是yingjie853@163.com,MSN:yingjie_853@hotmail.com
    QQ:278537061  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2007-09-19 21:03 | tan
    我想用ajax theme,但想用自己的CSS布局,可不可以???  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2007-09-20 15:53 | moonboat
    先粗略的看了一下,接下來慢慢學習!多謝樓主無私奉獻!
    普及struts2的人和開發struts2的人一樣偉大!  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2007-09-22 10:11 | sofee
    連接mysql出錯 無數據庫操作時正常 max幫幫忙 謝謝了

    嚴重: Servlet.service() for servlet default threw exception
    java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:404)
    at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:267)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:229)
    at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:221)
    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:150)
    at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:48)
    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:123)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    at   回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2007-09-22 10:11 | sofee
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:167)
    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:105)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:83)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:207)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:74)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:127)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    at org.apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.java:107)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:206)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:115)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
      回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2007-09-22 10:11 | sofee
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:143)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:121)
    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:170)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:123)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:50)
    at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:504)
    at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    at java.lang.Thread.run(Thread.java:595)
    Caused by: java.lang.ExceptionInInitializerError
    at com.stt.dao.Connections.getConn(Connections.java:10)
    at com.stt.dao.Products.<init>(Products.java:21)
    at com.stt.action.Login.execute(Login.java:33)
    ... 114 more
    Caused by: java.lang.NullPointerException
    at java.util.Properties$LineReader.readLine(Properties.java:365)
    at java.util.Properties.load(Properties.java:293)
    at com.stt.dao.DBConn.<clinit>(DBConn.java:13)
    ... 117 more  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分)[未登錄] 2007-09-25 14:07 | 冰點
    Hi max,你的文章寫的很好,我的struts2的學習很大以部分拜你所賜,但是最近怎么不見你寫關于struts2的文章了。我覺得你可以寫一點關于struts2的anntation配置吧,呵呵。但是個人覺得struts2自己帶的anntation配置用起來確實非常牽強,還需要你們這些牛人自己實現一個anntation啊  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2007-09-28 17:20 | xianglg
    同意冰點的,寫一篇關于struts2零配置的文章吧  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2007-10-01 18:12 | wuyundong
    我的郵箱wuyundong3000@163.com
    你寫的太好了啊  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2007-10-09 16:11 | workman
    一口氣看完了您寫的內容,非常感謝!(*^_^*)  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2007-10-24 09:50 | 信鴿
    真好。  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2007-10-30 14:22 | claymore
    謝謝你這么無私的貢獻!!!!  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分)[未登錄] 2007-11-12 09:51 | wind
    @冰點
    你想過annotation的好處嗎?
    如果你想過了,那就當我什么都沒說.如果你沒想過,而是在盲目的追求,那么我建議你冷靜下來好好的思考一下.annotation帶來了什么好處,我們為什么要使用annotation.  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分)[未登錄] 2007-11-12 09:56 | wind
    所謂零配置,根本就是個很SB的事情.

    為什么按上"零配置" 這么個很煽的名字?

    而事實上零配置就是說沒有配置,沒有配置就是硬編碼.就是沒有靈活性,擴展性.

    就像寫annotation一樣.當初把一些信息拿出來放到xml里,是一種可配置的做法,是一種進步.現在某些人盲目的提出一些倒退的觀點,居然也有很多盲目的人去追隨.我只是覺得很可悲.

    sun推出annotation特性,初衷是什么我說不好,但我就知道不是這么用的.annotation算什么?算配置還是算硬編碼?要改annotation就需要有java源文件,需要重新編譯,對么?

    xml有什么不好?xml地獄當然不好,xml過于冗長當然不好,但是解決的方法是不用xml了,回到從前,繼續硬編碼就好了嗎?
    這次炒菜有點咸了,那么以后就再也不用食鹽了,對嗎?  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2007-11-17 17:07 | 超級殲
    獲益匪淺,支持!  回復  更多評論
      
    # re: Struts 2有沒有類似struts1的MappingDispatcherAction的東東 2007-12-20 13:06 | Michael-Hu
    請問Max:在Struts 2中有沒有類似struts1的MappingDispatcherAction的東東  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2007-12-24 11:04 | study
    會出現異常的----我確實出現了nullpointerexecption
    不知道樓主知道具體原因么?謝謝  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2007-12-24 11:05 | study
    忘了說,是使用dwr2.0出現驗證表單時出現nullpointer的  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2008-01-02 11:38 | javer
    好,慢慢研究.  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2008-01-04 21:49 | 55
    55  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2008-01-17 15:06 | 無名小卒
    請問樓主:struts2的日期控件怎么使用?我想在頁面上判斷輸入是否正確,還有就是通過js給它賦值怎么辦啊?我始終得不到這個日期控制這個對象?  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2008-01-23 13:23 | llddy
    看完兄弟的帖子,我的心情竟是久久不能平復,正如老子所云:大音希聲,大象希形。我現在終于明白我缺乏的是什么了,正是兄弟那種對真理的執著追求和兄弟那種對理想的艱苦實踐所產生的厚重感。面對兄弟的帖子,我震驚得幾乎不能動彈了,兄弟那種裂紙欲出的大手筆,竟使我忍不住一次次的翻開兄弟的帖子,每看一次,贊賞之情就激長數分,我總在想,是否有神靈活在它靈秀的外表下,以至能使人三月不知肉味,使人有余音穿梁,三日不絕的感受。樓主,你寫得實在是太好了。我唯一能做的,就只有把這個帖子頂上去這件事了。兄弟的帖子實在是寫得太好了。文筆流暢,修辭得體,深得魏晉諸朝遺風,更將唐風宋骨發揚得入木三分,能在有生之年看見兄弟的這個帖子。實在是我三生之幸啊。看完兄弟的這個帖子之后,我竟感發生出一種無以名之的悲痛感――啊,這么好的帖子,如果將來我再也看不到了,那我該怎么辦?那我該怎么辦?直到我毫不猶豫的把兄弟的這個帖子收藏了。我內心的那種激動才逐漸平復下來。可是我立刻想到,這么好的帖子,倘若別人看不到,那么不是浪費兄弟的心血嗎?經過痛苦的思想斗爭,我終于下定決心,我要把這個帖子一直往上頂,往上頂!頂到所有人都看到為止遇到你之前,我對人世間是否有真正的圣人是懷疑的;而現在,我終于相信了!我曾經忘情于漢廷的歌賦,我曾經驚訝于李杜的詩才,我曾經流連于宋元的詞曲;但現在,我才知道我有多么淺薄!兄弟你的高尚情操太讓人感動了。在現在這樣一個物欲橫流的金錢社會里,竟然還能見到兄弟這樣的性情中人,無疑是我這輩子最大的幸運。讓我深深感受到了人性的偉大。兄弟的帖子,就好比黑暗中刺裂夜空的閃電,又好比撕開烏云的陽光,一瞬間就讓我如飲甘露,讓我明白了永恒的真理在這個世界上是真實存在著的。只有兄弟這樣具備廣闊胸懷和完整知識體系的人,才能作為這真理的唯一引言者。看了兄弟的帖子,讓我陷入了嚴肅的思考中,我認為,如果不把兄弟的帖子頂上去,就是對真理的一種背叛,就是對謬論的極大妥協。因此,我決定義無返顧的頂了說的好啊!我在這個論壇打滾這么多年,所謂閱人無數,就算沒有見過豬走路,也總明白豬肉是啥味道的。一看到兄弟的氣勢,我就覺得兄弟同在論壇里灌水的那幫小混蛋有著本質的差別,那憂郁的語調,那熟悉的簽名,還有字里行間高屋建瓴的辭藻。沒用的,兄弟,就算你怎么換馬甲都是沒有用的,你的億萬擁戴者早已經把你認出來了,你一定就是傳說中的最強ID。自從論壇改版之后,我就已經心灰意冷,對論壇也沒抱什么希望了,傳說已經幻滅,神話已經終結,留在論壇還有什么意思。沒想到,沒想到,今天可以再睹兄弟的風范,我激動得忍不住就在屏幕前流下了眼淚。是啊,只要在兄弟的帶領下,論壇就有希望了。我的內心再一次沸騰了,我胸腔里的血再一次燃燒了。兄弟的幾句話雖然簡單,卻概括扼要,一語道出了我們苦想多年的而不可得答案的幾個重大問題的根本。兄弟就好比論壇的明燈,兄弟就好比論壇的方向,兄弟就好比論壇的棟梁。有兄弟在,論壇的明天必將更好!大師的話真如“大音希聲掃陰翳”,猶如”撥開云霧見青天”,使我等網民看到了希望,看到了未來!晴天霹靂,醍醐灌頂或許不足以形容大師文章的萬一;巫山行云,長江流水更難以比擬大師的文才!黃鐘大呂,振聾發聵!你燭照天下,明見萬里;雨露蒼生,澤被萬方!透過你深邃的文字,我仿佛看到了你鷹視狼顧,龍行虎步的偉岸英姿;仿佛看到了你手執如椽大筆,寫天下文章的智慧神態;仿佛看見了你按劍四顧,江山無數的英武氣概將這帖逐句地看完這個帖子以后,我的心久久不能平靜,震撼啊!為什么會有如此好的帖子!我縱橫網絡bbs多年,自以為再也不會有任何帖子能打動我,沒想到今天看到了如此精妙絕倫的這樣一篇帖子。兄弟,是你讓我深深地理解了‘人外有人,天外有天’這句話。謝謝儂!在看完這帖子以后,我沒有立即回復,因為我生怕我庸俗不堪的回復會玷污了這網上少有的帖子。但是我還是回復了,因為覺得如果不能在如此精彩的帖子后面留下自己的網名,那我死也不會瞑目的!能夠在如此精彩的帖子后面留下自己的網名是多么驕傲的一件事啊!兄弟,請原諒我的自私!我知道無論用多么華麗的辭藻來形容兄弟您帖子的精彩程度都是不夠的,都是虛偽的,所以我只想說一句:您的帖子太好看了!我愿意一輩子的看下去!這篇帖子構思新穎,題材獨具匠心,段落清晰,情節詭異,跌宕起伏,主線分明,引人入勝,平淡中顯示出不凡的文學功底,可謂是字字珠璣,句句經典,是我輩應當學習之典范。就小說藝術的角度而言,這篇帖子不算太成功,但它的實驗意義卻遠遠大于成功本身。正所謂:“一馬奔騰,射雕引弓,天地都在我心中!”兄弟真不愧為無厘界新一代的開山怪!本來我已經對這個論壇失望了,覺得這個論壇沒有前途了,心里充滿了悲哀。但是看了你的這個帖子,又讓我對論壇產生了希望。是你讓我的心里重新燃起希望之火,是你讓我的心死灰復燃,是你拯救了我一顆撥涼撥涼的心!本來我決定不會在論壇回任何帖子了,但是看了你的帖子,我告訴自己這個帖子是一定要回的!這是百年難得一見的好貼啊!蒼天有眼啊,讓我在優生之年得以觀得如此精彩絕倫的帖子!兄弟,你要繼續努力啊!你是論壇的希望啊......  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2008-02-18 14:15 |
    當我使用ajax客戶端驗證時,驗證能正常運行,可是當輸入的數據都合法后,點擊“提交”時,頁面一點反應都沒有,但查看數據庫發現數據已經保存了。僅僅是頁面不跳轉。
    請問該怎么解決呢  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2008-03-07 11:06 | zhazha
    希望你還是能夠出書,能看出你寫BLOG的用心,
    所以你如果出書的話,也一定會用心的,寫的書應該很有價值,
    不會像市面上一些垃圾書,都是抄來抄去,一點價值也沒有~
    你出書我第一個支持~~·  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2008-03-07 21:46 | wow gold
    <a href=http://www.wowgolds.co.uk>wow gold</a> 非常實用啊  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2008-03-18 16:46 | lion
    @宋
    <result name="input">AjaxValidation.jsp</result>
    <result>AjaxValidation.jsp</result>

    你可以試試把struts.xml中的<result>AjaxValidation.jsp</result>
    這句去掉  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2008-04-11 16:25 | lyz
    寫的是非常好!先用了!呵呵,謝謝  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2008-04-11 23:52 | ipinko@126.com
    謝謝作者
    我照著做了1個,但是頁面打開的時候報錯了,然后可以象AJAX那樣驗證,但是action沒有反應.
    報錯:
    2008-4-11 23:49:50 uk.ltd.getahead.dwr.util.CommonsLoggingOutput info
    信息: Logging using commons-logging.
    2008-4-11 23:49:50 uk.ltd.getahead.dwr.util.CommonsLoggingOutput info
    信息: retrieved system configuration file: java.io.ByteArrayInputStream@12b644e
    2008-4-11 23:49:51 uk.ltd.getahead.dwr.util.CommonsLoggingOutput info
    信息: Creator 'pageflow' not loaded due to ClassNotFoundException. This is only an problem if you wanted to use it. Cause: Beehive/Weblogic Creator not available.
    2008-4-11 23:49:51 uk.ltd.getahead.dwr.util.CommonsLoggingOutput info
    信息: Creator 'spring' not loaded due to NoClassDefFoundError. This is only an problem if you wanted to use it. Cause: org/springframework/beans/factory/BeanFactory
    2008-4-11 23:49:51 uk.ltd.getahead.dwr.util.CommonsLoggingOutput info
    信息: Creator 'script' not loaded due to NoClassDefFoundError. This is only an problem if you wanted to use it. Cause: org/apache/bsf/BSFException
    2008-4-11 23:49:51 uk.ltd.getahead.dwr.util.CommonsLoggingOutput info
    信息: Converter 'jdom' not loaded due to NoClassDefFoundError. This is only an problem if you wanted to use it. Cause: org/jdom/Document
    2008-4-11 23:49:51 uk.ltd.getahead.dwr.util.CommonsLoggingOutput info
    信息: Converter 'hibernate' not loaded due to ClassNotFoundException. This is only an problem if you wanted to use it. Cause: Failed to find either org.hibernate.Hibernate or net.sf.hibernate.Hibernate.
    2008-4-11 23:49:51 uk.ltd.getahead.dwr.util.CommonsLoggingOutput info
    信息: Type 'org.jdom.Document' is not convertable due to missing converter 'jdom'. This is only an problem if you wanted to use it.
    2008-4-11 23:49:51 uk.ltd.getahead.dwr.util.CommonsLoggingOutput info
    信息: Type 'org.jdom.Element' is not convertable due to missing converter 'jdom'. This is only an problem if you wanted to use it.

    希望能得到指點  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2008-04-11 23:56 | ipinko@126.com
    @lion
    @宋
    <result name="input">AjaxValidation.jsp</result>
    <result>AjaxValidation.jsp</result>

    你可以試試把struts.xml中的<result>AjaxValidation.jsp</result>
    這句去掉

    我試過這句去掉也不行T___T  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2008-04-21 10:41 | 歡仔
    @ipinko@126.com
    我也想知道怎么跳轉。
    麻煩max大哥分析一下  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2008-05-16 00:36 | star
    受益匪淺.一看居然看了5個小時..博主的文章實在太引人了..是我入門學習與提高的好資料.看完你這再去看官方文檔效果好些吧` - -!  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2008-05-23 11:45 | fgrfg
    ga  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2008-05-27 16:58 | 小騙子
    在進行struts2 和ajax 驗證的時候,驗證信息出現的位置不是在標簽的后面,如何解決?給一個具體的步驟   回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2008-05-31 00:25 | alwaysqd@163.com
    十分感謝筆者的教程 解釋十分詳細具體 而且都有實現例子 太難得了 多謝  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2008-06-11 10:13 | !if
    max 大哥 您好!
    我是看您的教程學完 struts2 的,但是至于 struts2 與 dwr 結合的部分,不是很明白,
    1. struts2 與 dwr 結合時,dwr 怎么對數據進行效驗
    2. dwr 直接訪問業務邏輯層,什么時候需要使用 struts2
    3. dwr 如何實現 請求跳轉 ?

    如果您看到我的留言,愿意幫助我的話,請把答案發到我的油箱 :123141605@163.com 再就是您那有 dwr 的例子請給我一些
    謝謝  回復  更多評論
      
    # 兼容 2.1.x版本的改動 2008-06-20 19:17 | Leroy Zhu
    jsp 頁面內的 theme="ajax" 改為 theme="xhtml”

    2.1.x以后的版本不再支持ajax theme。  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2008-06-27 13:50 | DSDS
    HFD  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2008-07-03 11:52 | 大田斗
    感謝啊,覺得非常好!  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2008-07-12 21:03 | Struts 2愛好者
    強烈支持樓主!  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2008-07-23 13:36 | 楚人
    @CG
    請參考《如何更改Struts2的默認擴展名》 http://blog.csdn.net/lazymono/archive/2008/07/23/2695754.aspx  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2008-07-24 15:09 | 龐永慶
    你好 我不清楚你和哪個出版社聯系的寫書。我也是出版社的編輯,如果你真的想出版該書的話,可以和我聯系。
    我的郵箱:books_522008@yahoo.com.cn
    或者加我的MSN:pyq_19852008@hotmail.com  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2008-08-06 10:45 | LonQi
    這個例子不錯。但是我想問一下,在后面的部分說使用AJAX 來驗證name 和password。我怎么覺得跟 直接調用validate方法沒有什么區別啊。  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2008-08-06 17:24 | 最愛JavaEE
    我也剛接觸struts2, 以前用的是struts1.2
    來這里學了不少東西, 謝謝了
    期待LZ的更多文章  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2008-10-16 11:27 | sage.yun
    max大哥的無私奉獻精神值得我們大家學習啊。
    不能光max哥一個人分享經驗。大家都行動起來,發揚這種無私精神。
    max,好樣的!  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2008-11-26 16:20 | gqs
    max on java 文如其名

    謝謝!  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2008-11-27 11:20 | chaowei126
    支持 !!!!  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分)[未登錄] 2008-11-30 22:44 | 王剛
    很高興認識你摟住  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2008-12-09 15:55 | liang
    很好  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2008-12-14 00:28 | natty_boy
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">

    <struts>

    <package name="example" namespace="/example" extends="struts-default">

    <action name="HelloWorld" class="example.HelloWorld">
    <result>/example/HelloWorld.jsp</result>
    </action>

    <action name="Login_*" method="{1}" class="example.Login">
    <result name="input">/example/Login.jsp</result>
    <result type="redirect-action">Menu</result>
    </action>

    <action name="*" class="example.ExampleSupport">
    <result>/example/{1}.jsp</result>
    </action>

    <!-- Add actions here -->
    </package>
    </struts>
    這個是struts2包中的一個app 的 struts.xml配置
    我想知道配置中的 * 以及 {1} 表示什么
    <action name="Login_*" method="{1}" class="example.Login">
    <action name="*" class="example.ExampleSupport">
    <result>/example/{1}.jsp</result>
    </action>
    如何在 jsp 或者 action 中體現及運用  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2009-03-12 12:33 | Rique
    很好,正在學著用Dwr做一個小的項目,配合struts2的知識,又進了一步
      回復  更多評論
      
    # re: Struts 2與AJAX(第三部分)[未登錄] 2009-03-24 22:56 | h
    謝謝  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2009-04-02 17:47 | 舞命小丟
    struts提供這樣的模板是好的,但用起來不是很爽啊!  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分)[未登錄] 2009-09-26 20:32 | tom
    十分贊同你對國內it圖書的看法...
    為什么一定要照搬某種形式了?其實,按照作者自己的體會寫出來的書才有價值!現在市面上有太多濫竽充數的書了!中國人太浮躁了...
    不過,隨著現在人們的水平越來越高,哪些靠東搬西籌來的書,最終會被唾棄的!!!  回復  更多評論
      
    # re: Struts 2與AJAX(第三部分) 2011-01-24 16:55 | dpf
    不錯哦~  回復  更多評論
      
    主站蜘蛛池模板: 麻豆高清免费国产一区| 亚洲精品在线免费观看| 成年在线观看免费人视频草莓| 国产亚洲综合色就色| 卡一卡二卡三在线入口免费| 少妇人妻偷人精品免费视频| 亚洲黄色三级视频| 亚洲精品狼友在线播放| 免费在线观看污网站| 免费鲁丝片一级在线观看| 亚洲性线免费观看视频成熟| 亚洲精品免费视频| a色毛片免费视频| 精品国产呦系列在线观看免费 | 亚洲精品国产高清在线观看| 亚洲国产一成久久精品国产成人综合| 中国一级特黄高清免费的大片中国一级黄色片| 亚洲成在人线在线播放无码| 亚洲一区在线免费观看| 亚洲视频在线一区二区| 亚洲免费在线视频播放| 免费福利电影在线观看| 人妻在线日韩免费视频| 亚洲精品无码人妻无码| 亚洲日韩久久综合中文字幕| 亚洲日本人成中文字幕| 亚洲最大成人网色香蕉| 久久精品国产亚洲AV蜜臀色欲 | 亚洲视频在线观看地址| 亚洲va在线va天堂va888www| 国产在线98福利播放视频免费| 国产一精品一AV一免费| 亚洲AV日韩AV一区二区三曲| 亚洲精华国产精华精华液好用| 亚洲午夜精品一区二区| 亚洲国产精品第一区二区| 亚洲日本在线观看| 亚洲毛片在线免费观看| 亚洲香蕉久久一区二区 | 一级成人a做片免费| 精品国产免费人成网站|