<html:link page="/html-link.do">
Linking with the page attribute. </html:link> |
<html:link href="/struts-exercise-taglib/html-link.do">
Using Href </html:link> |
<html:link href="http://otherserver/strutsTut/html-link.do">
Using Href </html:link> |
<html:link action="/html-link">
Using Action attribute </html:link> |
<html:link page="/htmllink.do?doubleProp=3.3&longProp=32">
Double and long via hard coded changes </html:link> |
<html:link page="/html-link.do" paramId="booleanProperty" paramName="testbean"
paramProperty="nested.booleanProperty"> Boolean via paramId, paramName, and paramValue </html:link> |
<a href="/struts-exercise-taglib/html-link.do?booleanProperty=false">
Boolean via paramId, paramName, and paramValue </a> |
<%
java.util.HashMap newValues = new java.util.HashMap(); newValues.put("floatProperty", new Float(444.0)); newValues.put("intProperty", new Integer(555)); newValues.put("stringArray", new String[] { "Value 1", "Value 2", "Value 3" }); pageContext.setAttribute("newValues", newValues); %> ... <html:link action="/html-link" name="newValues"> Float, int, and stringArray via name (Map) </html:link> |
<html:messages property="property2" message="true" id="msg" header="messages.header" footer="messages.footer">
<tr><td><%= pageContext.getAttribute("msg") %></td></tr> </html:messages> |
鏍囩搴?/span>
|
璇存槑
|
HTML 鏍囩
|
鐢ㄦ潵鍒涘緩鑳藉鍜?/span>Struts 妗嗘灦鍜屽叾浠栫浉搴旂殑HTML 鏍囩浜や簰鐨?/span>HTML 杈撳叆琛ㄥ崟
|
Bean 鏍囩
|
鍦ㄨ闂?/span>JavaBeans 鍙?qiáng)鍏跺睘鎬э紝浠ュ強(qiáng)瀹氫箟涓涓柊鐨?/span>bean 鏃朵嬌鐢?/span>
|
Logic 鏍囩
|
綆$悊鏉′歡浜х敓鐨勮緭鍑哄拰瀵硅薄闆嗕駭鐢熺殑寰幆
|
Template 鏍囩
|
闅忕潃Tiles妗嗘灦鍖呯殑鍑虹幇錛屾鏍囪宸插紑濮嬪噺灝戜嬌鐢?/span>
|
Nested 鏍囩
|
澧炲己瀵瑰叾浠栫殑Struts 鏍囩鐨勫祵濂椾嬌鐢ㄧ殑鑳藉姏
|
灞炴?/span>
|
璇存槑
|
id
|
鍛藉悕鑷畾涔夋爣絳懼垱寤烘椂鐨勮剼鏈彉閲忓悕銆?/span>
|
name
|
鎸囧嚭鍏抽敭瀛楀鹼紝鍦ㄨ鍏抽敭瀛椾笅鍙互鎵懼埌涓涓瓨鍦ㄧ殑bean 銆傚鏋滅粰鍑轟簡(jiǎn)scope灞炴э紝鍒欎粎浠呭湪scope涓煡鎵俱傚惁鍒欙紝鏍規(guī)嵁鏍囧噯鐨勯『搴忓湪鍚勭scope涓煡鎵撅細(xì)(page, request, session, or application)銆?/span>
|
property
|
鎸囧嚭bean 涓殑鏌愪釜灞炴э紝鍙互鍦ㄥ叾涓绱㈠箋傚鏋滄病鏈夋爣鏄庯紝鍒欎嬌鐢ㄥ璞℃湰韜殑鍊箋?/span>
|
scope
|
瀹氫箟浜?/span>Bean鍦ㄥ摢涓寖鍥?/span>(page, request, session, or application)涓鏌ユ壘銆傚鏋滄病鏈夋爣鏄庢寜欏哄簭鏌ユ壘銆傝剼鏈彉閲?/span>(瑙?/span>id)灝嗗湪鐩稿悓鐨勮寖鍥翠腑鍒涘緩銆?/span>
|
Property="foo.bar.baz"
榪欑浉褰撲簬榪涜涓嬮潰鐨勮皟鐢細(xì) getFoo().getBar().getBaz()錛?/span> 鎴栬呭仛涓?/span>setter錛?/span> getFoo().getBar().setBaz(value)錛?/span> |
閿欒錛?/span>
<html:link href="'<%= "/" + name %>/index.jsp>'> 姝g‘錛?/span> <html:link href="'<%= "/" + name + "/index.jsp" %>'> // 琛ㄨ揪寮忓繀欏繪彁渚涙暣涓睘鎬у?/span> |
<html:html locale=\"true\">
姝よ浠g爜瑙f瀽鍚庯細(xì) <html lang=\"en\"> |
<html:base/>
姝よ浠g爜瑙f瀽鍚庯細(xì) <base href=\"http://www.mymain.com/myStrutsApp/testing.jsp\"> |
<html:img page=\"/logo.gif\" height=\"50\" width=\"200\" alt=\"Web Logo\"/>
|
<html:link page=\"/index.html\">Click demo</html:link>
姝よ浠g爜瑙f瀽鍚庯細(xì) <a href=\"/index.html\">Click demo</a> |
<html:form action=\"/login\" >
濡傛灉浣犳湁涓婅堪涓涓爣絳?/span> 錛岄偅涔堜綘鐨?/span>Struts閰嶇疆鏂囦歡鐨勫厓绱犱腑蹇呴』鏈変竴涓涓嬫樉紺轟負(fù)綺椾綋鐨勫厓绱狅細(xì) <action-mappings> <action path=\"/login\" type=\"com.javapro.struts.LoginAction\" name=\"loginForm\" scope=\"request\" input=\"/login.jsp\"> <forward name=\"success\" path=\"/mainMenu.jsp\"/> </action> . . . </action-mappings> // 榪欏氨鏄涓涓?/span>form鏍囩鏄拰form bean鐩稿叧鑱旂殑銆?/span> |
<body>
<html:form action=\"/login\" focus=\"password\"> User Name: <html:text property=\"userName\"/> <br>Password: <html:text property=\"password\"/> <br><html:submit/> </html:form> </body> 浠g爜瑙f瀽鍚庯細(xì) <body> <form name=\"loginForm\" method=\"post\" action=\"/myStrutsApp/login.do\"> User Name: <input type=\"text\" name=\"userName\" value=\"\"> <br>Password: <input type=\"text\" name=\"password\" value=\"\"> <br><input type=\"submit\" value=\"Submit\"> </form> <script language=\"JavaScript\" type=\"text/javascript\"> <!-- if (document.forms[\"loginForm\"].elements[\"password\"].type != \"hidden\") document.forms[\"loginForm\"].elements[\"password\"].focus() // --> </script> </body> |
<html:password property=\"password\" redisplay=\"false\"/>
|
<html:select property=\"color\" size=\"3\">
<html:option value=\"r\">red</html:option> <html:option value= \"g\">green</html:option> <html:option value= \"b\">blue</html:option> </html:select> |