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

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

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

    隨筆 - 71  文章 - 15  trackbacks - 0
    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    因為口渴,上帝創造了水;
    因為黑暗,上帝創造了火;
    因為我需要朋友,所以上帝讓你來到我身邊
    Click for Shaanxi xi'an, Shaanxi Forecast
    ╱◥█◣
      |田|田|
    ╬╬╬╬╬╬╬╬╬╬╬
    If only I have such a house!
    〖總在爬山 所以艱辛〗
    Email:myesjoy@yahoo.com.cn
    NickName:yesjoy
    MSN:myesjoy@hotmail.com
    QQ:150230516

    〖總在尋夢 所以苦痛〗

    常用鏈接

    留言簿(3)

    隨筆分類

    隨筆檔案

    文章分類

    文章檔案

    Hibernate在線

    Java友情

    Java認證

    linux經典

    OA系統

    Spring在線

    Structs在線

    專家專欄

    企業信息化

    大型設備共享系統

    工作流

    工作流產品

    網上購書

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    Jodd 是一個開源項目, http://jodd.sourceforge.net 有一個好用的 jsp 標簽,可以大大簡化有表單輸入的 controller

    ?

    使用 Jodd 的優點:

    <!--[if !supportLists]-->1.<!--[endif]-->簡化和統一controller,拋棄extends SimpleFormController,統一使用implements Controller的方式。

    <!--[if !supportLists]-->2.<!--[endif]-->簡化JSP頁面的bind,不需要一個字段一個字段的綁定。

    <!--[if !supportLists]-->3.<!--[endif]-->bean沒有任何要求,可以使用任意的bean做為formBean.

    ?

    使用方法簡介:

    <!--[if !supportLists]-->1.<!--[endif]-->jodd.jar放到web-inf->lib下,在web.xml里聲名標簽:

    < taglib >

    ???????
    < taglib-uri > jodd </ taglib-uri >

    ???????
    < taglib-location > /WEB-INF/lib/jodd.jar </ taglib-location >

    ????
    </ taglib >

    ?

    <!--[if !supportLists]-->2.<!--[endif]-->任意的一個javaBean做為FormBean

    package ?caike;?

    public ? class ?User?{

    ???????
    private ?String?userName;?

    ???????
    private ?String?password;
    ?????

    ???????
    public ?String?getPassword()?{

    ??????????????
    return ?password;

    ???????}?

    ???????
    public ? void ?setPassword(String?pwd)?{

    ??????????????
    this .password? = ?pwd;

    ???????}?

    ???????
    public ?String?getUserName()?{

    ??????????????
    return ?userName;

    ???????}?

    ???????
    public ? void ?setUserName(String?username)?{

    ??????????????
    this .userName? = ?username;

    ???????}
    ?

    }

    <!--[if !supportLists]-->3.<!--[endif]-->JSP頁面使用jodd tag:,比如對應用戶登錄頁面的

    <% @page?import = " caike.User " %>

    <% @taglib?uri = " jodd " ?prefix = " jodd " %>

    ?

    < jodd:form? beans ="user" ?scopes ="session" >

    < form? action ="my.htm" ?method ="post" ? >
    ?

    ????
    < table? width ="300" ?border ="0" ?cellspacing ="0" ?cellpadding ="0"

    ???????align
    ="center" ?class ="white" > ?

    ???????
    < tr >

    ???????????
    < td? height ="32" ?align ="right" ?width ="107" > 用戶名: </ td >

    ???????
    < td? height ="32" ?width ="193" >< input? type ="text" ?name ="userName"

    ??????????????class
    ="input" ?size ="20" > ? </ td > ???????? ?

    ???????
    </ tr >

    ???????
    < tr >

    ???????????
    < td? height ="33" ?align ="right" ?width ="107" > 密碼: </ td >

    ???????????
    < td? height ="33" ?width ="193" >< input? type ="password" ?name ="password"

    ??????????????class
    ="input" ?size ="21" ></ td >

    ???????
    </ tr >
    ??????

    ????????
    < tr >

    ???????????
    < td? height ="69" ?align ="center" ?colspan ="2" >

    ????????????
    < input? type ="submit" ?name ="Submit" ?value ="登錄" >

    ???????
    </ tr >

    ????
    </ table >

    </ form >

    </ jodd:form >

    ?

    <!--[if !supportLists]-->4.<!--[endif]-->Dispatch-servelt.xml中對controller的配置

    <bean id="myController" class="caike.MyController">????

    ??? </bean>

    ??? 不再需要這種方式:

    ??? <!--

    ?????? <bean id="myController" class="caike.MyFormController">????

    ?????? <property name="commandClass" value="caike" />??????

    ?????? <property name="formView" value="userForm" />???

    ?????? </bean>

    ??? -->

    <!--[if !supportLists]-->5.<!--[endif]-->controller中取出user

    package ?caike;?

    import ?javax.servlet.http.HttpServletRequest;

    import ?javax.servlet.http.HttpServletResponse;?

    import ?jodd.bean.BeanUtil;?

    import ?org.springframework.web.servlet.ModelAndView;

    import ?org.springframework.web.servlet.mvc.Controller;

    ?

    public ? class ?MyController? implements ?Controller?{

    ?

    ???????
    public ?ModelAndView?handleRequest(HttpServletRequest?request,

    ?????????????????????HttpServletResponse?response)?
    throws ?Exception?{

    ?

    ??????????????User?user?
    = ? new ?User();

    ??????????????BeanUtil.load(user,?request);

    ??????????????System.out.println(
    " 用戶名: " ? + ?user.getUserName()? + ? " ?密碼: " ? + ?user.getPassword());

    ??????????????
    return ? null ;

    ???????}

    ?

    }

    ?

    需要注意的地方:

    表單中對應的名字 name javaBean 里對應的屬性名要相同。

    <input type="text" name="userName"

    ????????????? class="input" size="20">

    public class User {

    ?????? private String userName;

    .......

    ?參考:

    http://m.tkk7.com/calvin/archive/2005/08/24/10914.html

      花錢的年華    簡化Spring(4)--View層

    posted on 2006-11-10 15:20 ★yesjoy★ 閱讀(1389) 評論(0)  編輯  收藏 所屬分類: Spring學習
    主站蜘蛛池模板: 亚洲无成人网77777| 亚洲高清国产拍精品26U| 亚洲人av高清无码| 88xx成人永久免费观看| 亚洲AV午夜成人片| a毛片全部播放免费视频完整18| 亚洲午夜无码片在线观看影院猛| 精品国产日韩亚洲一区91| 免费高清资源黄网站在线观看| 国产又黄又爽又刺激的免费网址| 亚洲熟妇无码av另类vr影视| 久久综合AV免费观看| 亚洲午夜久久久久久久久久| 岛国精品一区免费视频在线观看| 国产国拍亚洲精品福利 | 中文精品人人永久免费| 国产亚洲美日韩AV中文字幕无码成人| 九九久久国产精品免费热6| 久久久国产精品福利免费| 亚洲av永久无码精品古装片| 免费人妻无码不卡中文字幕系 | 亚洲AV综合色区无码一区爱AV | 亚洲成AV人片在WWW| 国产精品美女自在线观看免费| 麻豆va在线精品免费播放| 国产精品久久久亚洲| 久久免费观看国产精品| 久久久久se色偷偷亚洲精品av| 日韩电影免费在线观看视频| 美女被免费视频网站a| 在线a亚洲v天堂网2019无码| 精品国产日韩亚洲一区91| 国产亚洲欧洲Aⅴ综合一区| 91大神免费观看| 亚洲色无码专区一区| ZZIJZZIJ亚洲日本少妇JIZJIZ| 午夜免费福利小电影| 亚洲日韩精品A∨片无码加勒比| 久久精品国产精品亚洲下载| 在线a免费观看最新网站| 麻豆91免费视频|