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

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

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

    龍行天下

      政 博
    隨筆 - 23, 文章 - 0, 評論 - 12, 引用 - 0
    數(shù)據(jù)加載中……

    Hibernate查詢解決方案

         摘要: 第一部分: Hibernate 提供的查詢接口或其方法 (此部分不做深究,請參考 hibernate 手冊) ????? ?????? 1 。...  閱讀全文

    posted @ 2006-05-03 20:03 feingto 閱讀(429) | 評論 (0)編輯 收藏

    struts在URI后面?zhèn)鲄?shù)的問題

    在struts標(biāo)簽<html:link>的page屬性指定的URI后面?zhèn)鬟f參數(shù)可以有幾種方式:
    1.若明確參數(shù)名和參數(shù)值則直接在URI后輸出,
    如:<html:link page="/test.do?action=add">add</html:link>

    2.對于參數(shù)值不確定的,paramName和paramProperty來輸出,用paramId屬性指定參數(shù)名。
    對于paramName指定的對象應(yīng)該存在于page、request、session、application其中之一。一般來說,是從Action類傳過來的,作為request的屬性之一(requst.setAttribute("name",object))。
    如果paramName指定的對象是action的ActionForm,則無需使用request.setAttribute方法。
    例:<html:link page="/test.do" paramId="userid" paramName="uid">uname</html:link>
    若參數(shù)值是一個bean對象的屬性值(比如ActionForm,或者集合中存放的對象)則:
    <html:link page="/test.do" paramId="userid" paramName="user" paramProperty="uid">uname</html:link>

    3.若兩個參數(shù),一個確定一個不確定,則是以上兩種方法的結(jié)合,即:
    <html:link page="/test.do?action=modify" paramId="userid" paramName="uid">modify</html:link>

    4.對于多個參數(shù)的問題,可以使用一個HashMap集合對象來存放所有的參數(shù)名及對應(yīng)的參數(shù)值的方式,paramName屬性值指定為該HashMap集合對象即可。
    舉例:
    <%
    //代碼理想的位置應(yīng)該是在action中
    //可以在jsp頁面測試
    ? java.util.HashMap pms = new java.util.HashMap();
    ? pms.put("code", "001002");
    ? pms.put("name", "tester");
    ? pms.put("alias", new String[]{"matin","jack"});
    ? request.setAttribute("params", pms);
    %>
    <html:link action="/test.do" name="params" >test</html:link>
    編譯后的結(jié)果:<a href="/test.do?code=001002&name=tester&alias=matin&alias=jack">test</a>
    這種方式雖然可以解決傳多參數(shù)的問題,但是實現(xiàn)起來也比較麻煩,特別是對記錄集中的數(shù)據(jù)逐條列出的時候

    5.針對有的網(wǎng)友在<html:link>標(biāo)簽中嵌入使用jsp腳本(scriptlet)的問題,
    例如:
    <html:link page="/test.do?code=<%=varible%>">add</html:link>,這種寫法是錯誤的,是無法編譯的。
    有的網(wǎng)友認(rèn)為在struts標(biāo)簽內(nèi)是不允許使用jsp腳本的,這種說法也不準(zhǔn)確。如果前面的寫法改成:
    <html:link page="<%="/test.do?code="+varible%>">add</html:link>,就可以被執(zhí)行,但是要注意URL相對路徑的問題。

    雖然在struts標(biāo)簽中嵌入jsp腳本不是真正意義上的struts應(yīng)用,但是有時在委曲求全的情況下也只能如此了,除非使用自定義標(biāo)簽。比如在form表單中可能需要根據(jù)具體數(shù)據(jù)讓某個字段是只讀的,就可以用嵌入jsp腳本來實現(xiàn):
    <%
    boolean rdonly=false;
    if(2==2) rdonly=true;
    %>
    <html:text property="userid" readonly="<%=rdonly%>" />


    6.另外一種比較變態(tài)的方法,既不是真正意義上的struts,也不符合xml規(guī)范。那就是在<a>標(biāo)簽中用<bean:write>標(biāo)簽輸出參數(shù)值。
    如:<a href="test.do?uid=<bean:write name="user" property="userid"/>&name=<bean:write name="user" property="username"/>">test</a>

    posted @ 2006-05-03 20:02 feingto 閱讀(887) | 評論 (0)編輯 收藏

    struts錯誤和信息的處理

    1. 錯誤和信息的處理 .

    首先在資源文件中定義錯誤信息和普通信息 . :MessageResources.properties 中定義如下 :

    java 代碼 :?



    #
    # Resources
    for testing <html:errors> tag.
    #

    errors.header=<table>
    errors.footer=</table>
    errors.prefix=<tr><td>
    errors.suffix=</td></tr>

    property1error1=Property 1,
    Error 1
    property2error1=Property 2,
    Error 1
    property2error2=Property 2,
    Error 2
    property2error3=Property 2,
    Error 3
    property3error1=Property 3,
    Error 1
    property3error2=Property 3,
    Error 2
    globalError=Global
    Error

    #
    # Resources
    for testing <html:messages> tag.
    #

    messages.header=<table>
    messages.footer=</table>

    property1message1=Property 1, Message 1
    property2message1=Property 2, Message 1
    property2message2=Property 2, Message 2
    property2message3=Property 2, Message 3
    property3message1=Property 3, Message 1
    property3message2=Property 3, Message 2
    globalMessage=Global Message

    ?



    在程序中定義錯誤和信息類 , 這個例子寫在 JSP

    java 代碼 :?



    <%
    ? ? ? ActionErrors errors =
    new ActionErrors();
    ? ? ? errors.add("property1",
    new ActionError("property1error1"));
    ? ? ? errors.add("property2",
    new ActionError("property2error1"));
    ? ? ? errors.add("property2",
    new ActionError("property2error2"));
    ? ? ? errors.add("property2",
    new ActionError("property2error3"));
    ? ? ? errors.add("property3",
    new ActionError("property3error1"));
    ? ? ? errors.add("property3",
    new ActionError("property3error2"));
    ? ? ? errors.add(ActionErrors.GLOBAL_ERROR,
    new ActionError("globalError"));
    ? ? ? request.setAttribute(Globals.ERROR_KEY, errors);

    ? ? ? ActionMessages messages =
    new ActionMessages();
    ? ? ? messages.add("property1",
    new ActionMessage("property1message1"));
    ? ? ? messages.add("property2",
    new ActionMessage("property2message1"));
    ? ? ? messages.add("property2",
    new ActionMessage("property2message2"));
    ? ? ? messages.add("property2",
    new ActionMessage("property2message3"));
    ? ? ? messages.add("property3",
    new ActionMessage("property3message1"));
    ? ? ? messages.add("property3",
    new ActionMessage("property3message2"));
    ? ? ? messages.add(ActionMessages.GLOBAL_MESSAGE,
    new ActionMessage("globalMessage"));
    ? ? ? request.setAttribute(Globals.MESSAGE_KEY, messages);
    ? ? %>

    ?





    顯示錯誤 :

    java 代碼 :?



    <html:errors property="property1" />
    <html:errors property="property2" />

    ?


    顯示信息 :

    java 代碼 :?



    <html:messages property="property1" message="
    true " id="msg" header="messages.header" footer="messages.footer">
    ? ? ? ? ? ? <tr>
    ? ? ? ? ? ? ? <td>
    ? ? ? ? ? ? ? ? ? ? ?<%= pageContext.getAttribute("msg") %>
    ? ? ? ? ? ? ? </td>
    ? ? ? ? ? ? </tr>
    ? ? ? ? ? </html:messages>

    <html:messages message="
    true " id="msg" header="messages.header" footer="messages.footer">
    ? ? ? ? ? ? <tr>
    ? ? ? ? ? ? ? <td>
    ? ? ? ? ? ? ? ?<%= pageContext.getAttribute("msg") %>
    ? ? ? ? ? ? ? </td>
    ? ? ? ? ? ? </tr>
    </html:messages>

    ?

    ?

    posted @ 2006-05-03 20:02 feingto 閱讀(1033) | 評論 (0)編輯 收藏

    僅列出標(biāo)題
    共3頁: 上一頁 1 2 3 
    主站蜘蛛池模板: 亚洲尹人九九大色香蕉网站 | 亚洲免费视频网站| heyzo亚洲精品日韩| 日韩成人精品日本亚洲| 毛片免费观看网站| 涩涩色中文综合亚洲| 青青草a免费线观a| 亚洲欧美成人一区二区三区| 全免费毛片在线播放| 亚洲综合校园春色| 在线免费观看一级片| 亚洲精品无码久久久久久| 在线a人片天堂免费观看高清| 亚洲av无码不卡久久| 一二三四在线观看免费高清中文在线观看| 亚洲高清不卡视频| 久久WWW免费人成人片| 国产色在线|亚洲| 日韩免费一区二区三区| 狠狠综合亚洲综合亚洲色| 亚洲国产成人精品91久久久| 一个人看的免费观看日本视频www 一个人看的免费视频www在线高清动漫 | 久久精品国产96精品亚洲| 久久狠狠躁免费观看2020| 亚洲韩国在线一卡二卡| 波多野结衣中文字幕免费视频 | 一级做a爰片性色毛片免费网站 | 亚洲精品高清视频| 69视频在线是免费观看| 国产亚洲中文日本不卡二区| 免费一级特黄特色大片在线观看| 国产精品免费久久久久电影网| 亚洲精品国产精品乱码不卡√| 日韩在线永久免费播放| 亚洲熟妇自偷自拍另欧美| 亚洲免费日韩无码系列| 久久这里只精品热免费99| 亚洲色大成网站www尤物| 亚洲精品成a人在线观看| 暖暖免费日本在线中文| 亚洲中文无码永久免|