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

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

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

    隨筆-34  評(píng)論-1965  文章-0  trackbacks-0

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

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

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

    什么是DWR

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

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

    其實(shí)DWR原理也不復(fù)雜,它先在web.xml中配置一個(gè)Servlet,映射到特定的路徑(通常是%CONTEXT_PATH%/dwr/*)。這個(gè)Servlet的作用就是初始化要暴露給Javascript調(diào)用的Java類(通過(guò)dwr.xml進(jìn)行配置),并生成相應(yīng)的代理的Javascript類代碼。在XHR請(qǐng)求到來(lái)的時(shí)候,Servlet負(fù)責(zé)將請(qǐng)求的參數(shù)變成對(duì)應(yīng)的Java對(duì)象,并以其為參數(shù)調(diào)用目標(biāo)Java方法,并將返回值轉(zhuǎn)化為Javascript代碼。詳情請(qǐng)參考:http://getahead.ltd.uk/dwr/

    Struts 2與DWR

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

    首先,到以下站點(diǎn)https://dwr.dev.java.net/files/documents/2427/47455/dwr.jar下載DWR的1.1.4版本的JAR包。需要注意的是,DWR雖然已經(jīng)發(fā)布2.0版本,但它與1.1.4有很大的區(qū)別,所以請(qǐng)大家不要使用2.0版本,否則會(huì)出現(xiàn)異常的;

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

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

    接下來(lái),配置web.xml文件,內(nèi)容如下:

    <?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>
       
    <!-- 開(kāi)始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>
       
    <!-- 結(jié)束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

    通過(guò)以上配置,我們可以將DWRValidator中的方法暴露為Javascript可以調(diào)用的遠(yuǎn)程接口。

    在正確完成以上步驟之后,我們發(fā)布運(yùn)行一下應(yīng)用程序,在瀏覽器地址欄中輸入http://localhost:8080/Struts2_Ajax3/dwr/,應(yīng)該會(huì)出現(xiàn)如下頁(yè)面:

    DWR Servlet默認(rèn)輸出頁(yè)面
    圖3 DWR Servlet默認(rèn)輸出頁(yè)面

     接下來(lái),我們要開(kāi)始編寫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

    上述代碼一目了然,相信大家已經(jīng)很熟悉了。下面,我們?cè)賮?lái)看看表單校驗(yàn)的配置代碼:

    <!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

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

    接下來(lái)的是JSP的代碼,內(nèi)容如下:

    <%@ 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

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

    最后是Struts 2的配置文件,內(nèi)容如下所示:

    <?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

    最后發(fā)布運(yùn)應(yīng)用程序,在瀏覽器地址欄中輸入http://localhost:8080/Struts2_Ajax3/AjaxValidation!input.action出現(xiàn)如下圖所示頁(yè)面:

    AjaxValidation頁(yè)面輸出
    圖4 AjaxValidation頁(yè)面輸出

    在文本框中輸入錯(cuò)誤的值使頁(yè)面出現(xiàn)錯(cuò)誤提示信息,如下圖所示:

    AjaxValidation頁(yè)面錯(cuò)誤提示
    圖5 AjaxValidation頁(yè)面錯(cuò)誤提示

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

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

    Firebug中查看XHR請(qǐng)求
    圖6 Firebug中查看XHR請(qǐng)求

    這就證明你在文本框失去焦出時(shí),Struts 2會(huì)發(fā)送XHR請(qǐng)求到服務(wù)器以對(duì)該文本框值進(jìn)行校驗(yàn)。有興趣的朋友可以通過(guò)Firebug,研究XHR的請(qǐng)求與響應(yīng),這樣可以加深對(duì)DWR工作原理的理解。

    何時(shí)使用AJAX表單校驗(yàn)

    雖然在Struts 2實(shí)現(xiàn)AJAX表單校驗(yàn)是一件非常簡(jiǎn)單的事,但我建議大家不要在所有的場(chǎng)合都使用這個(gè)功能,原因可以分為以下幾個(gè)方面:

    1. AJAX校驗(yàn)在服務(wù)器上進(jìn)行數(shù)據(jù)校驗(yàn),可能會(huì)比較耗時(shí);
    2. AJAX校驗(yàn)可能會(huì)過(guò)于頻繁,加重服務(wù)器的負(fù)載;
    3. 一些普通的校驗(yàn),只需要使用純Javascript便可以實(shí)現(xiàn)。

    讀到這里,有的朋友可能會(huì)問(wèn):“那么什么時(shí)候才應(yīng)該使用AJAX表單校驗(yàn)?zāi)兀?#8221;答案其實(shí)很簡(jiǎn)單,當(dāng)我們的校驗(yàn)在頁(yè)面加載時(shí)還不能夠確定的情況下,就應(yīng)該使用這個(gè)功能。例如,注冊(cè)用戶時(shí),校驗(yàn)用戶名是否已經(jīng)存在;或者校驗(yàn)涉及過(guò)多的頁(yè)務(wù)邏輯等。

    現(xiàn)在讓我們來(lái)改造一下上述例子,對(duì)于name我們可以使用AJAX校驗(yàn),但對(duì)于其它的字段應(yīng)該使用純Javascript的校驗(yàn)。

    在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代碼片段

    用于模擬用戶注冊(cè)的場(chǎng)境,當(dāng)然在真實(shí)情況應(yīng)該在數(shù)據(jù)庫(kù)中檢查用戶是否存在。

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

            <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代碼片段

    對(duì)比早前的JSP代碼,大家可以看出我將<s:form />的theme改成了“ajax_xhtml”,這個(gè)theme不是Struts 2自帶,需要自定義。另外,除了Name使用了ajax的theme之外,其它的表單標(biāo)簽的theme都為xhtml,如此一來(lái)便可以實(shí)現(xiàn)只有當(dāng)Name文本框失去焦點(diǎn)時(shí)才發(fā)生AJAX表單校驗(yàn)。

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

    <#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表單校驗(yàn)所用的Javascript庫(kù),以便theme為ajax的表單標(biāo)簽使用。

    <#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

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

    最后發(fā)布運(yùn)行應(yīng)用程序,大家可以發(fā)現(xiàn)在Password與Age的校驗(yàn),只有在表單提交時(shí)才發(fā)生,而且是純Javascript的校驗(yàn)。不過(guò),以上代碼還不是很完善,在行為上有些BUG。

    總結(jié)

    Struts 2相比一些其它的框架,在實(shí)現(xiàn)AJAX方面的確簡(jiǎn)單很多。更激動(dòng)人心的是Struts 2的標(biāo)簽庫(kù)支持基于模板的輸出,使得開(kāi)發(fā)者可以跟據(jù)自身的需要方便地改變標(biāo)簽的行為。

    在將要發(fā)布的Struts 2.1版本中,AJAX表單校驗(yàn)將不再使用DWR,統(tǒng)一使用DOJO實(shí)現(xiàn),詳情請(qǐng)參考:http://struts.apache.org/2.0.9/docs/ajax-validation.html

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

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

    @plantegg
    寫書的話,可以更詳盡一點(diǎn)。不過(guò),盡管不是寫書,我也最我的努力寫這個(gè)BLOG的。

    @cleaner
    對(duì)不起,最近比較忙;所以更新慢了下來(lái)。  回復(fù)  更多評(píng)論
      
    # re: Struts 2與AJAX(第三部分) 2007-08-23 16:57 | 牧碼人
    樓主,我強(qiáng)烈支持你的義舉,當(dāng)然我也是受益者,頂!!!!!!!!!!  回復(fù)  更多評(píng)論
      
    # re: Struts 2與AJAX(第三部分) 2007-08-27 14:31 | pxcong
    當(dāng)驗(yàn)證成功后,怎樣實(shí)現(xiàn)跳轉(zhuǎn)的呢? 能幫我講講嗎?  回復(fù)  更多評(píng)論
      
    # re: Struts 2與AJAX(第三部分) 2007-08-31 15:19 | mark
    Max 公布一個(gè)銀行帳號(hào)吧!咱們不但在精神支持你,而且也要在經(jīng)濟(jì)上支持你!  回復(fù)  更多評(píng)論
      
    # 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!!  回復(fù)  更多評(píng)論
      
    # re: Struts 2與AJAX(第三部分) 2007-09-04 10:19 | Jarwang
    請(qǐng)問(wèn)?????????max


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

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

    最后,給頁(yè)面調(diào)用.

    可問(wèn)題是:::::::::::記錄沒(méi)有排序.....盡管用了 order by orderName?????

    tks!!!!!!!!!!!!!!!!!!!!!!!  回復(fù)  更多評(píng)論
      
    # re: Struts 2與AJAX(第三部分) 2007-09-05 00:06 | Max
    @mark
    謝謝您的支持。不過(guò),我寫這個(gè)BLOG的目的不是為了錢。而且我覺(jué)得真正值得經(jīng)濟(jì)支持的是Struts 2的項(xiàng)目的開(kāi)發(fā)者,他們才是真正的英雄!  回復(fù)  更多評(píng)論
      
    # re: Struts 2與AJAX(第三部分) 2007-09-05 00:38 | Max
    # re: Struts 2與AJAX(第三部分) 2007-09-05 10:46 | jiew
    @wsc
    很感謝你這一系列教程 ,我剛看完,收獲很多 。謝了
    我會(huì)繼續(xù)關(guān)注你的BLOG的。  回復(fù)  更多評(píng)論
      
    # 問(wèn)一個(gè)Struts2配置的問(wèn)題 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 "";
    }
    }

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

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

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

    嚴(yán)重: 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   回復(fù)  更多評(píng)論
      
    # 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)
      回復(fù)  更多評(píng)論
      
    # 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  回復(fù)  更多評(píng)論
      
    # re: Struts 2與AJAX(第三部分)[未登錄](méi) 2007-09-25 14:07 | 冰點(diǎn)
    Hi max,你的文章寫的很好,我的struts2的學(xué)習(xí)很大以部分拜你所賜,但是最近怎么不見(jiàn)你寫關(guān)于struts2的文章了。我覺(jué)得你可以寫一點(diǎn)關(guān)于struts2的anntation配置吧,呵呵。但是個(gè)人覺(jué)得struts2自己帶的anntation配置用起來(lái)確實(shí)非常牽強(qiáng),還需要你們這些牛人自己實(shí)現(xiàn)一個(gè)anntation啊  回復(fù)  更多評(píng)論
      
    # re: Struts 2與AJAX(第三部分) 2007-09-28 17:20 | xianglg
    同意冰點(diǎn)的,寫一篇關(guān)于struts2零配置的文章吧  回復(fù)  更多評(píng)論
      
    # re: Struts 2與AJAX(第三部分) 2007-10-01 18:12 | wuyundong
    我的郵箱wuyundong3000@163.com
    你寫的太好了啊  回復(fù)  更多評(píng)論
      
    # re: Struts 2與AJAX(第三部分) 2007-10-09 16:11 | workman
    一口氣看完了您寫的內(nèi)容,非常感謝!(*^_^*)  回復(fù)  更多評(píng)論
      
    # re: Struts 2與AJAX(第三部分) 2007-10-24 09:50 | 信鴿
    真好。  回復(fù)  更多評(píng)論
      
    # re: Struts 2與AJAX(第三部分) 2007-10-30 14:22 | claymore
    謝謝你這么無(wú)私的貢獻(xiàn)!!!!  回復(fù)  更多評(píng)論
      
    # re: Struts 2與AJAX(第三部分)[未登錄](méi) 2007-11-12 09:51 | wind
    @冰點(diǎn)
    你想過(guò)annotation的好處嗎?
    如果你想過(guò)了,那就當(dāng)我什么都沒(méi)說(shuō).如果你沒(méi)想過(guò),而是在盲目的追求,那么我建議你冷靜下來(lái)好好的思考一下.annotation帶來(lái)了什么好處,我們?yōu)槭裁匆褂胊nnotation.  回復(fù)  更多評(píng)論
      
    # re: Struts 2與AJAX(第三部分)[未登錄](méi) 2007-11-12 09:56 | wind
    所謂零配置,根本就是個(gè)很SB的事情.

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

    而事實(shí)上零配置就是說(shuō)沒(méi)有配置,沒(méi)有配置就是硬編碼.就是沒(méi)有靈活性,擴(kuò)展性.

    就像寫annotation一樣.當(dāng)初把一些信息拿出來(lái)放到xml里,是一種可配置的做法,是一種進(jìn)步.現(xiàn)在某些人盲目的提出一些倒退的觀點(diǎn),居然也有很多盲目的人去追隨.我只是覺(jué)得很可悲.

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

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

    希望能得到指點(diǎn)  回復(fù)  更多評(píng)論
      
    # 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>
    這句去掉

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

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

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

    謝謝!  回復(fù)  更多評(píng)論
      
    # re: Struts 2與AJAX(第三部分) 2008-11-27 11:20 | chaowei126
    支持 !!!!  回復(fù)  更多評(píng)論
      
    # re: Struts 2與AJAX(第三部分)[未登錄](méi) 2008-11-30 22:44 | 王剛
    很高興認(rèn)識(shí)你摟住  回復(fù)  更多評(píng)論
      
    # 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>
    這個(gè)是struts2包中的一個(gè)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 中體現(xiàn)及運(yùn)用  回復(fù)  更多評(píng)論
      
    # re: Struts 2與AJAX(第三部分) 2009-03-12 12:33 | Rique
    很好,正在學(xué)著用Dwr做一個(gè)小的項(xiàng)目,配合struts2的知識(shí),又進(jìn)了一步
      回復(fù)  更多評(píng)論
      
    # re: Struts 2與AJAX(第三部分)[未登錄](méi) 2009-03-24 22:56 | h
    # re: Struts 2與AJAX(第三部分) 2009-04-02 17:47 | 舞命小丟
    struts提供這樣的模板是好的,但用起來(lái)不是很爽啊!  回復(fù)  更多評(píng)論
      
    # re: Struts 2與AJAX(第三部分)[未登錄](méi) 2009-09-26 20:32 | tom
    十分贊同你對(duì)國(guó)內(nèi)it圖書的看法...
    為什么一定要照搬某種形式了?其實(shí),按照作者自己的體會(huì)寫出來(lái)的書才有價(jià)值!現(xiàn)在市面上有太多濫竽充數(shù)的書了!中國(guó)人太浮躁了...
    不過(guò),隨著現(xiàn)在人們的水平越來(lái)越高,哪些靠東搬西籌來(lái)的書,最終會(huì)被唾棄的!!!  回復(fù)  更多評(píng)論
      
    # re: Struts 2與AJAX(第三部分) 2011-01-24 16:55 | dpf
    不錯(cuò)哦~  回復(fù)  更多評(píng)論
      
    主站蜘蛛池模板: 中文字幕亚洲精品资源网| 一级毛片免费不卡在线| 免费中文字幕一级毛片| 亚洲AV日韩AV一区二区三曲| 最新猫咪www免费人成| 亚洲自国产拍揄拍| 在人线av无码免费高潮喷水| 国产日本亚洲一区二区三区| 在线观看免费高清视频| 伊人久久亚洲综合影院首页| 国产成人免费高清激情视频| 亚洲中文字幕久久精品无码VA | 亚洲国产成人手机在线观看| 成人免费视频一区| 亚洲色成人四虎在线观看| 巨胸喷奶水视频www网免费| 亚洲人成欧美中文字幕| 免费无码又爽又刺激毛片| 成人亚洲国产精品久久| 婷婷综合缴情亚洲狠狠尤物| 污污视频免费观看网站| 中国亚洲女人69内射少妇| 99精品免费视频| 91亚洲一区二区在线观看不卡| 亚洲香蕉免费有线视频| 亚洲一区二区三区久久久久| 97无码免费人妻超级碰碰夜夜| 色噜噜的亚洲男人的天堂| 亚洲国产成人久久一区WWW| 久久久久久久国产免费看| 亚洲爆乳无码专区| 最近免费最新高清中文字幕韩国| 亚洲成aⅴ人在线观看| 成人免费无码大片a毛片软件| 亚洲hairy多毛pics大全| 亚洲国产综合久久天堂| 国产日韩一区二区三免费高清| 亚洲视频在线免费观看| 皇色在线视频免费网站| 亚洲av第一网站久章草| ZZIJZZIJ亚洲日本少妇JIZJIZ|