日韩一区二区三区免费播放,中文字幕欧美日韩精品 ,国产精品久久久久久久久妇女http://www.aygfsteel.com/freeman1984/category/42535.html STANDING ON THE SHOULDERS OF GIANTSzh-cnFri, 28 Oct 2011 16:20:14 GMTFri, 28 Oct 2011 16:20:14 GMT60發布一個struts2的插件學習版,用來支持rest風格 url的參數綁定。http://www.aygfsteel.com/freeman1984/archive/2011/10/28/362261.html瘋狂瘋狂Fri, 28 Oct 2011 15:53:00 GMThttp://www.aygfsteel.com/freeman1984/archive/2011/10/28/362261.htmlhttp://www.aygfsteel.com/freeman1984/comments/362261.htmlhttp://www.aygfsteel.com/freeman1984/archive/2011/10/28/362261.html#Feedback0http://www.aygfsteel.com/freeman1984/comments/commentRss/362261.htmlhttp://www.aygfsteel.com/freeman1984/services/trackbacks/362261.htmlinfo1/admin/joe.do,同時講參數id,group,userName 綁定到action的對應的屬性上。
  閱讀全文

瘋狂 2011-10-28 23:53 發表評論
]]>
struts2.0.1升級到struts2.2.3遇到的一些語法細節。 http://www.aygfsteel.com/freeman1984/archive/2011/08/09/356066.html瘋狂瘋狂Tue, 09 Aug 2011 02:23:00 GMThttp://www.aygfsteel.com/freeman1984/archive/2011/08/09/356066.htmlhttp://www.aygfsteel.com/freeman1984/comments/356066.htmlhttp://www.aygfsteel.com/freeman1984/archive/2011/08/09/356066.html#Feedback0http://www.aygfsteel.com/freeman1984/comments/commentRss/356066.htmlhttp://www.aygfsteel.com/freeman1984/services/trackbacks/356066.html1.
 ognl 靜態方法處理
<s:property value="@com.e104.rd.util.DynaEnvConstants@getInt('ROWS_PER_PAGE')"/>
struts2.0.1 支持
 
struts2.2.3 默認不支持,需要修改struts.xml
<constant name="struts.ognl.allowStaticMethodAccess" value="true" />

2. 參數傳遞的問題
 
var url = '../Search/ResumeSearchAction_loadResumeList.action?pageNo=<s:property value="pageNo"/> ';
     var param = {
   target : url, 
   method : 'post',
   form: "searchConditionForm",
   div: "resume_list_div"
  }
 
<form id="searchConditionForm" name="searchConditionForm" method="post" action="">
  <input type="hidden" name="pageNo" id="pageNo" value="1">
  。。。。。。。。。
</form>
 
url 后面跟pageNo 參數,form里有pageNo 參數,
 
struts2.0.1 支持,struts2.2.3 不支持,需要把url后參數刪除,且struts2.2.3 參數傳遞要比前版嚴格 ,
所以要測試,遇到參數傳遞的問題時候,再修改。

3.導入actions.xml;
struts2.0.1: <include file="**\actions.xml"/>
struts2.2.3:
  <include file="/**/actions.xml"/>
4.默認攔截器的名字修改:
 struts2.0.1:<interceptor-ref name="token-session">
 struts2.2.3:<interceptor-ref name="tokenSession">

5.
struts2.0.1
<result name="LOGOUT" type="redirect-action">
struts2.2.3:
<result name="LOGOUT" type="redirectAction">
遇到攔截器名字,result type名字不一致,可以去查看
struts2-core-2.2.3.jar/struts-default.xml

6.

<pao:FilterSelect id="jobExp.disTime_origin" name="jobExp.disTime_t" source="DataCode_4" filter="0" locale="#session['test.locale']" headerKey="0" headerValue=" 請選擇 "/>

         更新成綠色部分

<pao:FilterSelect id="jobExp.disTime_origin" name="jobExp.disTime_t" source="DataCode_4" filter="{0}" locale="#session['test.locale']" headerKey="0" headerValue=" 請選擇 "/>



7.

然后就是 json

               com.googlecode.jsonplugin.JSONUtil  需要替換   org.apache.struts2.json.JSONUtil




其他可參考官網

https://cwiki.apache.org/S2WIKI/troubleshooting-guide-migrating-from-struts-20x-to-21x.html#TroubleshootingguidemigratingfromStruts2.0.xto2.1.x-UpdateDependencies

轉自:http://accpchf.iteye.com/blog/1128492



瘋狂 2011-08-09 10:23 發表評論
]]>
淺析struts中的ExecuteAndWaitInterceptor,以及簡單例子http://www.aygfsteel.com/freeman1984/archive/2010/09/25/332787.html瘋狂瘋狂Fri, 24 Sep 2010 16:59:00 GMThttp://www.aygfsteel.com/freeman1984/archive/2010/09/25/332787.htmlhttp://www.aygfsteel.com/freeman1984/comments/332787.htmlhttp://www.aygfsteel.com/freeman1984/archive/2010/09/25/332787.html#Feedback0http://www.aygfsteel.com/freeman1984/comments/commentRss/332787.htmlhttp://www.aygfsteel.com/freeman1984/services/trackbacks/332787.html  大致把源碼中類前面的一段注釋給翻譯一下:
    
     1 ExecuteAndWaitInterceptor很適合在后臺長時間運行的action時,他可以可為用戶一個友好的等待界面,例如進度條。
    2  不在默認的攔截stack 里面,使用的時候需要配置,但必須是在攔截堆棧的最后一個。
   大致配置如下:
  <action name="test" method="test" class="com.joe.web.action.ActionTest">
         <interceptor-ref name="completeStack"/>
         <interceptor-ref name="execAndWait">
             <param name="delay">1000</param>
            <param name="delaySleepInterval">50</param>
       </interceptor-ref>
      <result name="wait">wait.jsp</result>
      <result name="success">success.jsp</result>
   </action>    3 使用的時候需要配置一個名為wait的result,并指向自己的等待頁面,如果沒有struts

將使用FreeMarker代替,通過使用FreemarkerResult動態注入一個等待頁面:struts提供的面板頁面可見于:
org/apache/struts2/interceptor/wait.ftl
內容大致如下:

<html>
    <head>
        <meta http-equiv="refresh" content="5;url=<@s.url includeParams="none"/>"/>
    </head>
    <body>
        Please wait while we process your request...
        <p/>

        This page will reload automatically and display your request when it is completed.
    </body>
</html>

其中的includeParams參數取值為

none,不把參數參加到url參數中

all,是把getpost中的參數參加到url參數中

get,是只把get中的參數參加到url參數中

     execAndWait攔截器有2個參數:
         delay :意思是初始等待多少秒才出現等待頁面。當在這個等待時間內action執行完畢,就不用出現wai界面,如果不配,一開始就會出現。
       delaySleepInterval:每個對少時間檢查action是否執行完畢。
     
  -------------
大致的原理是:strus遇到這種配置了execAndWait的action會另外起一個線程來執行,這個線程名叫BackgroundProcess,并通過一個done屬性的變化來標準執行情況,struts將此線程放到session中,頁面每隔一段時間去檢查是done==true?  如果不是,就據需返回wai頁面,否則返回主action的返回界面。
 BackgroundProcess大致源碼:
 
public BackgroundProcess(String threadName, final ActionInvocation invocation, int threadPriority) {
        
this.invocation = invocation;
        
this.action = invocation.getAction();
        
try {
            
final Thread t = new Thread(new Runnable() {
                
public void run() {
                    
try {
                        beforeInvocation();
                        result 
= invocation.invokeActionOnly();
                        afterInvocation();
                    }
 catch (Exception e) {
                        exception 
= e;
                    }


                    done 
= true;
                }

            }
);
            t.setName(threadName);
            t.setPriority(threadPriority);
            t.start();
        }
 catch (Exception e) {
            exception 
= e;
        }

    }

當這個action結束后會將done屬性設置為true表示執行結束,正是每次去檢查這個屬性來判別。

   攔截器主要源碼:

 

 if ((!executeAfterValidationPass || secondTime) && bp == null) {
                bp = getNewBackgroundProcess(name, actionInvocation, threadPriority);
                session.put(KEY + name, bp);//放入session
                performInitialDelay(bp); // first time let some time pass before showing wait page
                secondTime = false;
            }

            if ((!executeAfterValidationPass || !secondTime) && bp != null && !bp.isDone()) {//是否完畢
                actionInvocation.getStack().push(bp.getAction());//將后臺action的相關信息push到statck,時候的頁面可是使用        
        if (TokenHelper.getToken() != null) {
                    session.put(TokenHelper.getTokenName(), TokenHelper.getToken());
                }

                Map results = proxy.getConfig().getResults();
                if (!results.containsKey(WAIT)) {//如果沒有配置wait,struts將為你inject一個
                    LOG.warn("ExecuteAndWait interceptor has detected that no result named 'wait' is available. " +
                            "Defaulting to a plain built-in wait page. It is highly recommend you " +
                            "provide an action-specific or global result named '" + WAIT +
                            "'.");
                    // no wait result? hmm -- let's try to do dynamically put it in for you!

                    //we used to add a fake "wait" result here, since the configuration is unmodifiable, that is no longer
                    //an option, see WW-3068
                    FreemarkerResult waitResult = new FreemarkerResult();
                    container.inject(waitResult);
                    waitResult.setLocation("/org/apache/struts2/interceptor/wait.ftl");
                    waitResult.execute(actionInvocation);

                    return Action.NONE;
                }

                return WAIT;
            } else if ((!executeAfterValidationPass || !secondTime) && bp != null && bp.isDone()) {//如果執行完畢return  bp.getResult();
                session.remove(KEY + name);
                actionInvocation.getStack().push(bp.getAction());

                // if an exception occured during action execution, throw it here
                if (bp.getException() != null) {
                    throw bp.getException();
                }

                return bp.getResult();
            } else {
                // this is the first instance of the interceptor and there is no existing action
                // already run in the background, so let's just let this pass through. We assume
                // the action invocation will be run in the background on the subsequent pass through
                // this interceptor
                return actionInvocation.invoke();
            }

。

一個簡單的例子(不包含lib):
  /Files/freeman1984/execAndWait.rar
  
  


   

瘋狂 2010-09-25 00:59 發表評論
]]>
stuts2 返回xmlhttp://www.aygfsteel.com/freeman1984/archive/2010/09/17/332278.html瘋狂瘋狂Fri, 17 Sep 2010 03:13:00 GMThttp://www.aygfsteel.com/freeman1984/archive/2010/09/17/332278.htmlhttp://www.aygfsteel.com/freeman1984/comments/332278.htmlhttp://www.aygfsteel.com/freeman1984/archive/2010/09/17/332278.html#Feedback0http://www.aygfsteel.com/freeman1984/comments/commentRss/332278.htmlhttp://www.aygfsteel.com/freeman1984/services/trackbacks/332278.html關于Struts2 返回XML的問題

1. Action其實是一個POJO,所以我們可以直接把Action生成一個XML.只要把Result Type設為xslt就可以了:
      <action name="XmlModel" class="cpu.XmlModelAction">
            <result name="success" type="xslt" />
      </action>
里面包含了Action的所有屬性,還有Locale等信息. 可以在瀏覽器里輸入http://localhost:8080/XXX/XXX/XmlModel.action來看.

2. 為了定制自己想要的XML,我們可以輸入參數來輸出自己想要的Action的某個屬性(屬性可以是一個List).
      <action name="XmlModel" class="cpu.XmlModelAction">
            <result name="success" type="xslt">
                  <param name=”exposedValue”>modelList</param>
            </result>
      </action>

3. 如果有多于一個屬性呢.加個大括號圍起來
      <action name="XmlModel" class="cpu.XmlModelAction">
            <result name="success" type="xslt">
                  <param name=”exposedValue”>{modelList, type}</param>
            </result>
      </action>

4. 以上三個方法都是由Action 來控制生成格式.那么對于我們這種控制欲很強的人來說并不滿足,最好是由我們自己來定義生成樣子.那么這時我們就要做的就是在屬性里生成一個 org.w3c.dom.Document屬性.注意:不要用org.dom4j.Document類.要不會出現轉化錯誤,死得很慘.
      <action name="XmlModel" class="cpu.XmlModelAction">
      <result name="success" type="xslt">
            <param name="exposedValue">xmlDoc</param>
      </result>
      </action>
上面的xmlDoc就是 Action里的org.w3c.dom.Document類型.

5. 我只會用并且非要用org.dom4j.Document類怎么辦? 那就在最后轉化成 org.w3c.dom.Document:
Java代碼 復制代碼
  1. import java.io.ByteArrayInputStream;     
  2. import java.io.IOException;     
  3.       
  4. import javax.xml.parsers.DocumentBuilderFactory;     
  5. import javax.xml.parsers.ParserConfigurationException;     
  6.       
  7. import org.xml.sax.SAXException;     
  8.       
  9. public class XmlUtil {     
  10.      
  11.       private XmlUtil() {     
  12.       }     
  13.       
  14.       public static org.w3c.dom.Document XmlString2W3cDom(String xml)     
  15.                   throws SAXException, IOException, ParserConfigurationException {     
  16.             byte[] byteArray = xml.getBytes("UTF-8");     
  17.             ByteArrayInputStream baos = new ByteArrayInputStream(byteArray);     
  18.             DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();     
  19.             org.w3c.dom.Document doc = factory.newDocumentBuilder().parse(baos);     
  20.             return doc;     
  21.       }     
  22.       
  23.       public static org.dom4j.Document W3c2Dom4j(org.w3c.dom.Document doc) {     
  24.             if (doc == null) {     
  25.                  return (null);     
  26.             }     
  27.             org.dom4j.io.DOMReader xmlReader = new org.dom4j.io.DOMReader();     
  28.             return (xmlReader.read(doc));     
  29.       }     
  30.       
  31. }     

Action里加上一句: xmlDoc = Xmlutil.XmlString2W3cDom(dom4jDoc.asXML());
上面的xmlDoc就是 Action里的org.w3c.dom.Document類型.

6. 用org.dom4j.dom.DOMDocumentFactory()來建立 Document.而不要用DocumentHelper.createDocument()來產生.最后直接cast一下.
 
public String execute() throws UnsupportedEncodingException, ParserConfigurationException, SAXException, IOException {     
  1.   InfoCpuService cpuSvc = null;     
  2.   cpuSvc = (InfoCpuService) ServiceLocator.getInstance().getService(InfoCpuService.class);     
  3.       
  4.   modelList = cpuSvc.getModels(prodBrand);     
  5.       
  6.   log.info(ReflectionToStringBuilder.toString(this));     
  7.      
  8.  org.dom4j.Document dom4jDoc = new org.dom4j.dom.DOMDocumentFactory().createDocument();     
  9.     
  10.                Element root = dom4jDoc.addElement("root");     
  11.  root.addAttribute("prodType""CPU");     
  12.     
  13. for (Object o : modelList) {     
  14.   root.addElement("model").addAttribute("name", (String) o);     
  15.  }     
  16.      
  17. //xmlDoc = XmlUtil.XmlString2W3cDom(doc.asXML());     
  18.  xmlDoc = (Document) dom4jDoc;     
  19.      
  20.   HttpServletResponse response = ServletActionContext.getResponse();     
  21.   response.setContentType("text/xml;charset=UTF-8");     
  22.   response.setHeader("Cache-Control""no-cache");     
  23.        
  24.  return SUCCESS;     
  25.     

其中三句代碼是為了防止生成中文亂碼
   HttpServletResponse response = ServletActionContext.getResponse();
   response.setContentType("text/xml;charset=UTF-8");
   response.setHeader("Cache-Control", "no-cache");

7. 在action中返回類型最好設置為import org.w3c.dom.Document;
private Document retXML;  

配置格式為:
Java代碼
  1. <action name="XmlModel" class="com.XmlModelAction">   
  2.            <result name="success" type="xslt">   
  3.                  <param name=”exposedValue”>retXML</param>   
  4.            </result>   
  5.  </action>  
轉自:http://skyful.javaeye.com/blog/505775

瘋狂 2010-09-17 11:13 發表評論
]]>
Struts2 ognl中的#、%和$符號用法說明http://www.aygfsteel.com/freeman1984/archive/2010/09/01/330653.html瘋狂瘋狂Wed, 01 Sep 2010 15:44:00 GMThttp://www.aygfsteel.com/freeman1984/archive/2010/09/01/330653.htmlhttp://www.aygfsteel.com/freeman1984/comments/330653.htmlhttp://www.aygfsteel.com/freeman1984/archive/2010/09/01/330653.html#Feedback0http://www.aygfsteel.com/freeman1984/comments/commentRss/330653.htmlhttp://www.aygfsteel.com/freeman1984/services/trackbacks/330653.html

#、%和$符號在OGNL表達式中經常出現,而這三種符號也是開發者不容易掌握和理解的部分。在這里筆者簡單介紹它們的相應用途。

1.#符號的用途一般有三種。
   1)訪問非根對象屬性,例如示例中的#session.msg表達式,由于Struts 2中值棧被視為根對象,所以訪問其他非根對象時,需要加#前綴。實際上,#相當于ActionContext. getContext();#session.msg表達式相當于ActionContext.getContext().getSession(). getAttribute(”msg”) 。
    2)用于過濾和投影(projecting)集合,如示例中的persons.{?#this.age>20}。
    3)用來構造Map,例如示例中的#{'foo1':'bar1','foo2':'bar2'}。

2.%符號
%符號的用途是在標志的屬性為字符串類型時,計算OGNL表達式的值。如下面的代碼所示:
構造Map
<s:set name="foobar" value="#{'foo1':'bar','foo2':'bar2'}" />

<p>The value of key "foo1" is <s:property value="#foobar['foo1']" /></p>

<p>不使用%:<s:url value="#foobar['foo1']" /></p>

<p>使用%:<s:url value="%{#foobar['foo1']}" /></p>

3.$符號
$符號主要有兩個方面的用途。

   在國際化資源文件中,引用OGNL表達式,例如國際化資源文件中的代碼:reg.agerange=國際化資源信息:年齡必須在${min}同${max}之間。

    在Struts 2框架的配置文件中引用OGNL表達式,例如下面的代碼片斷所示:
<validators>
    <field name=”intb”>
            <field-validator type=”int”>
            <param name=”min”>10</param>
            <param name=”max”>100</param>
            <message>BAction-test校驗:數字必須為${min}為${max}之間!</message>
        </field-validator>
    </field>
</validators>


本文來自CSDN博客,轉載請標明出處:http://blog.csdn.net/pengyouchuan/archive/2009/01/05/3712933.aspx



瘋狂 2010-09-01 23:44 發表評論
]]>
strtuts2 異常之Could not create and/or set value back on to object http://www.aygfsteel.com/freeman1984/archive/2010/06/22/324133.html瘋狂瘋狂Tue, 22 Jun 2010 03:14:00 GMThttp://www.aygfsteel.com/freeman1984/archive/2010/06/22/324133.htmlhttp://www.aygfsteel.com/freeman1984/comments/324133.htmlhttp://www.aygfsteel.com/freeman1984/archive/2010/06/22/324133.html#Feedback2http://www.aygfsteel.com/freeman1984/comments/commentRss/324133.htmlhttp://www.aygfsteel.com/freeman1984/services/trackbacks/324133.html   最終解決辦法:對應于表單的bean 需要空的構造函數。

瘋狂 2010-06-22 11:14 發表評論
]]>
struts2 文件上傳和下載,以及部分源碼解析http://www.aygfsteel.com/freeman1984/archive/2010/06/02/322533.html瘋狂瘋狂Wed, 02 Jun 2010 03:37:00 GMThttp://www.aygfsteel.com/freeman1984/archive/2010/06/02/322533.htmlhttp://www.aygfsteel.com/freeman1984/comments/322533.htmlhttp://www.aygfsteel.com/freeman1984/archive/2010/06/02/322533.html#Feedback0http://www.aygfsteel.com/freeman1984/comments/commentRss/322533.htmlhttp://www.aygfsteel.com/freeman1984/services/trackbacks/322533.html閱讀全文

瘋狂 2010-06-02 11:37 發表評論
]]>
Struts2插件 Config Browser Pluginhttp://www.aygfsteel.com/freeman1984/archive/2010/01/18/310015.html瘋狂瘋狂Mon, 18 Jan 2010 15:17:00 GMThttp://www.aygfsteel.com/freeman1984/archive/2010/01/18/310015.htmlhttp://www.aygfsteel.com/freeman1984/comments/310015.htmlhttp://www.aygfsteel.com/freeman1984/archive/2010/01/18/310015.html#Feedback1http://www.aygfsteel.com/freeman1984/comments/commentRss/310015.htmlhttp://www.aygfsteel.com/freeman1984/services/trackbacks/310015.htmlConfig Browser Plugin — Struts2運行期間可通過此插件查看Struts2的配置情況。

又是一個很不錯的插件,使用方法也很簡單.

在你下載的struts\lib目錄下應該可以找到該插件struts2-config-browser-plugin

然后把該jar復制到你的工程目錄下:WEB-INF/lib下

然后,啟動你的項目

輸入:http://localhost:8008/你的發布工程名/config-browser/index.action

然后你就可以看到如下的統計:



瘋狂 2010-01-18 23:17 發表評論
]]>
struts2 標簽記錄http://www.aygfsteel.com/freeman1984/archive/2009/11/02/300709.html瘋狂瘋狂Mon, 02 Nov 2009 06:59:00 GMThttp://www.aygfsteel.com/freeman1984/archive/2009/11/02/300709.htmlhttp://www.aygfsteel.com/freeman1984/comments/300709.htmlhttp://www.aygfsteel.com/freeman1984/archive/2009/11/02/300709.html#Feedback0http://www.aygfsteel.com/freeman1984/comments/commentRss/300709.htmlhttp://www.aygfsteel.com/freeman1984/services/trackbacks/300709.html

1,iterator

<s:iterator id="obj" value="list" status="index">

 

 

<!---輸出當前元素的屬性-->

<s:property value="property"/>

 

<!---輸出當前迭代元素的索引-->

<s:property value="#index.index"/>

 

<!---輸出當前迭代了幾個元素-->

<s:property value="#index.count"/>

 

<!---返回當前迭代元素的索引是否為奇數-->

<s:property value="#index.odd"/>

 

<!---返回當前迭代元素的索引是否為偶數-->

<s:property value="#index.event"/>

 

<!---返回當前元素是否為第一個-->

<s:property value="#index.first"/>

 

<!---返回當前元素是否為最后一個-->

<s:property value="#index.last"/>

 

<!---返回當前元素下標-->

<s:property value="#index.getCount()" />

 

 

</s:iterator>



瘋狂 2009-11-02 14:59 發表評論
]]>
主站蜘蛛池模板: 克拉玛依市| 常德市| 余江县| 剑阁县| 札达县| 电白县| 仁怀市| 林口县| 临西县| 吉林市| 琼中| 上思县| 景东| 唐山市| 漳浦县| 高安市| 云梦县| 乳山市| 胶州市| 阜南县| 茌平县| 绥芬河市| 甘南县| 周宁县| 盘锦市| 石家庄市| 昌吉市| 乐业县| 九江市| 咸阳市| 井冈山市| 论坛| 苍梧县| 于田县| 泊头市| 广汉市| 和静县| 阿克| 英超| 扶余县| 扬州市|