日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【web开发学习笔记】Structs2 Result学习笔记(三)带參数的结果集

發布時間:2024/4/14 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【web开发学习笔记】Structs2 Result学习笔记(三)带參数的结果集 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Result學習筆記(三)帶參數的結果集

第一部分:代碼

//前端 <head> <meta http-equiv="Content-Type" content="text/html; charset=GB18030" /><title>Insert title here</title> </head><body><ol><li><a href="user/user?type=1">傳參數</a></li></ol> </body> </html>
//web.xml <struts><constant name="struts.devMode" value="true" /><package name="user" namespace="/user" extends="struts-default"><action name="user" class="com.struts2.user.action.UserAction"><result type="redirect">/user_success.jsp?t=${type}</result></action> </package> </struts> //類包 package com.struts2.user.action; import com.opensymphony.xwork2.ActionSupport; public class UserAction extends ActionSupport {private int type;public int getType() {return type;}public void setType(int type) {this.type = type;}@Overridepublic String execute() throws Exception {return "success";} }
//展示 </head><body>User Success!from valuestack: <s:property value="t"/><br/>from actioncontext: <s:property value="#parameters.t"/><s:debug></s:debug></body> </html>

第二部分:分析

1.<li><a href="user/user?type=1">傳參數</a></li>,鏈接訪問user命名空間里面的user action,并對action傳遞參數type = 1;2.<package name="user" namespace="/user" extends="struts-default"><action name="user" class="com.struts2.user.action.UserAction"><result type="redirect">/user_success.jsp?t=${type}</result></action> </package> <result type="redirect">/user_success.jsp?t=${type}</result>? 目的: ? ? 跟據配置文件構造user action對象,并進行設置參數。由client發出請求后,由web.xml的配置文件構造UserAction對象時,請求中出傳遞的數值會傳遞到構造的對象中。注意:一次request僅僅有一個值棧.
? ? result要求<result type="redirect">/user_success.jsp?t=${type}</result>,要求重定向到到user_success.jsp,并要求去除
action中的type值。當中type="redirect"表示是client跳轉,

3.from valuestack: <s:property value="t"/><br/> //從值棧取值from actioncontext: <s:property value="#parameters.t"/> <span style="white-space:pre"> </span>//從actioncontext取值



總結

以上是生活随笔為你收集整理的【web开发学习笔记】Structs2 Result学习笔记(三)带參数的结果集的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。