WML和HTML差不多。在sourceforge.net下載了struts用的wml標簽。在工程中配置好。
使用wml標簽庫的go標簽。如下
<anchor title="link">
??????????? <bean:write name="item" property="title"/>
??????????? <wml:go page="/article/ViewAction.do" method="post"/>
</anchor>
wml:go中page寫鏈接地址。和html:link標簽一樣,如果使用link屬性,前面不加context path。method屬性指定請求的方式,取值有post和get。
如果請求路徑時需要帶參數怎么辦?wml語言的寫法:
<anchor title="GO">
???GO
???<go method="post" href="" />
???<postfield name="nPartNum" value="$PageNum" />
</anchor>
那使用WML標簽庫的寫法就是:
<anchor title="go">
???GO
???<wml:postfield property="articleid" value="1"></wml:postfield>
???<wml:go page="/article/ViewAction.do" method="post"/>
</anchor>
如果想從輸入框中獲取參數值那該如何呢?HTML中的做法就很費時了。看看WML中的辦法吧:
第<input type="text" name="PageNum" size="2" value="1" format="N"/>頁
<anchor title="go">
???GO
???<wml:postfield property="articleid" value="$PageNum"></wml:postfield>
???<wml:go page="/article/ViewAction.do" method="post"/>
</anchor>
看看簡單吧。wml:postfield中的value屬性的值是由$PageNum賦值而來的。$PageNum這種寫法是WML中變量的寫法。將input的值直接當作變量來用,很方便吧。
雖然HTML中可以像下面這樣使用,這也只能直接獲取input中的值,但是要想將參數放到request中,還需要寫端script。比起WML來差遠了。
<input id="gogonumber" name="gogonum" type="text" size="3"/> <a href="javascript:next(gogonum.value-1, <%=allpages%>)">go</a>
總的來說struts的wml標簽庫和html標簽庫用法來說差不多。但是wml標簽庫中的標簽沒有將所有的wml標簽全部對應上。
最后說句,今天從sourceforge.net下載struts-xml項目還是挺難的。原因不在sourceforge.net,應該在網通或者電信。
posted on 2007-01-26 19:39
卜清楚 閱讀(1483)
評論(1) 編輯 收藏 所屬分類:
wml