- 浏览: 761514 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (573)
- Java基础 (76)
- C++基础 (5)
- hibernate (5)
- struts (4)
- spring (1)
- webservice (7)
- AjaX基础 (0)
- JS脚本 (53)
- 正则表达式 (5)
- html脚本 (30)
- 数据库基础 (54)
- 工作相关 (49)
- 其他 (30)
- Linux (9)
- web服务器 (17)
- JSP (13)
- eclipse (6)
- 面试题相关 (20)
- XML (3)
- Apache common (2)
- 生活 (35)
- VMware (1)
- log4j (9)
- BeanUtils (2)
- 设计模式 (3)
- UML (1)
- UNIX (1)
- ibats (5)
- GT-Grid (17)
- ABAP学习 (17)
- ABAP (35)
- ABAP--ALV (11)
- ABAP--WEBDIMPRO (0)
- abap-sample (1)
- BEMS (2)
- flex (33)
- GIS技术 (3)
最新评论
目标:
实现从flex页面向后台的服务框架(struts2)传输参数。
实现:
在flex页面中添加<HTTPService>标签,在事件触发向服务器发送请求时将数据加载在request中向服务器发送,其中的url属性填写服务器的请求路径(.../*.action一定要填相对路径,前面不要加"/"),这样的话struts2的action可以接收到相同名字的属性。
环境:
1.flex编辑使用 Flex Builder3.0.2.214193
2.struts2使用 MyEclipse6.5
3.服务器 Tomcat 5.5
------------------------------flex-------------------------------
flex页面:
其中:_url.action为用户定义的请求,该页面向struts2发送两个参数:userName,pswWord
-----------------------------java----------------------------------
web.xml代码
服务器配置文件
struts.xml代码(放在src目录下)
服务器配置文件:其中的action的name属性一定要和服务器请求的属性一致,其后面的class属性要与java中Action的实体类的位置对应
action代码
Action实体类:其中的属性名要与flex页面传来的参数名保持一致,并添加g&s方法。然后再在execute()方法里描述这个action具体需要做的事情。
最后的return返回值可以设成null,因为flex不会受struts的驱使跳转页面。
p.s. 如果不部署到eclipse上运行的话,_url填写完整的http协议路径
实现从flex页面向后台的服务框架(struts2)传输参数。
实现:
在flex页面中添加<HTTPService>标签,在事件触发向服务器发送请求时将数据加载在request中向服务器发送,其中的url属性填写服务器的请求路径(.../*.action一定要填相对路径,前面不要加"/"),这样的话struts2的action可以接收到相同名字的属性。
环境:
1.flex编辑使用 Flex Builder3.0.2.214193
2.struts2使用 MyEclipse6.5
3.服务器 Tomcat 5.5
------------------------------flex-------------------------------
flex页面:
其中:_url.action为用户定义的请求,该页面向struts2发送两个参数:userName,pswWord
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundColor="#f6f6f6" backgroundGradientColors="[#f6f6f6, #AA1220]" fontSize="12"> <mx:Label text="用户名:" x="23" y="61" id="txt"/> <mx:TextInput id="userName" x="77" y="59"/> <mx:Label text="密码:" x="35" y="91"/> <mx:TextInput id="pswWord" x="77" y="89"/> <mx:Button label="提交" click='my_HS.send()' x="185" y="121"/> <mx:HTTPService id="my_HS" url="_url.action" method="post" > <mx:request> <userName>{userName.text}</userName> <pswWord>{pswWord.text}</pswWord> </mx:request> </mx:HTTPService> </mx:Application>
-----------------------------java----------------------------------
web.xml代码
服务器配置文件
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app>
struts.xml代码(放在src目录下)
服务器配置文件:其中的action的name属性一定要和服务器请求的属性一致,其后面的class属性要与java中Action的实体类的位置对应
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name="struts.action.extension" value="action,do,webwork" /> <package name="simple" extends="struts-default"> <action name="_url" class="test.action.GetUserName"> <result name="success">index.jsp</result> </action> </package> </struts>
action代码
Action实体类:其中的属性名要与flex页面传来的参数名保持一致,并添加g&s方法。然后再在execute()方法里描述这个action具体需要做的事情。
最后的return返回值可以设成null,因为flex不会受struts的驱使跳转页面。
package test.action; import com.opensymphony.xwork2.ActionSupport; public class GetUserName extends ActionSupport{ public String userName; public String pswWord; public String getPswWord() { return pswWord; } public void setPswWord(String pswWord) { this.pswWord = pswWord; } public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } public String execute(){ System.out.println("there it is"); String s = getText(userName); System.out.println(s+":"+pswWord); return SUCCESS; } }
p.s. 如果不部署到eclipse上运行的话,_url填写完整的http协议路径
评论
3 楼
Clover139
2011-10-14
我也很想知道,struts2怎么向Flex返回结果呢?
2 楼
gedoua
2010-10-15
请问struts2怎么像flex返回结果啊?
1 楼
gedoua
2010-10-07
正是想要的,太好了!感觉分享哈
发表评论
-
便携电脑使用详情
2011-04-03 18:30 795便携机 IBM T410I 配置:I3-380M /2G/3 ... -
Geoserver如何访问shapefile或PostGIS数据库
2010-08-20 13:11 2565数据库, Geoserver, PostGIS, shapef ... -
flex checkbox tree
2010-08-10 16:40 1945网上遇到很多需要在Tree控件添加CheckBox等控件的问题 ... -
flex读取post方式的request参数
2010-08-09 21:52 1438目标: 使用flex在不发送请求的情况下,从request中 ... -
flex登录
2010-08-05 16:19 909<?xml version="1.0" ... -
GNU、GPL和LGPL
2010-07-30 16:52 11771.GNU 和 Linux 的关系 GN ... -
计算机世界里的法律:软件使用许可的一些知识
2010-07-30 16:43 938在Internet上的软件一般 ... -
企业用户合法使用 GPL/LGPL 自由软件的指导(zz)
2010-07-30 16:39 1334本文给出了一些指导性 ... -
地图服务器的选择
2010-07-30 13:17 1497地图服务器的比较与选 ... -
MapServer学习笔记
2010-07-30 09:49 21091、MapServer简介 M ... -
Mapserver起步
2010-07-29 19:13 1850Mapserver起步 Mapserver是比较著名的 ... -
MapXtreme Java 版 --- 100% 纯Java 地图应用服务器
2010-07-28 13:42 1893企业可以通过地图实现 ... -
开源的地图服务器
2010-07-28 13:24 1985完全商业化的地 ... -
flexbuilder打包swc
2010-07-12 11:12 2692flexbuilder打包swc地址: http://blo ... -
flex 加载图片时的相关问题
2010-07-06 16:31 1143桌面背景布局 居中 平鋪 拉伸 DesktopBack ... -
OpenLayers项目分析
2010-07-02 14:39 1909摘要:OpenLayers 是由 Meta ... -
GIS 标准体系
2010-07-02 12:25 1399GIS 标准体系 我可没想 ... -
三种地理参考信息模型:WMS,WFS,WCS
2010-07-02 12:08 1102关键字: gis wms wfs wcs OGC ... -
Flex的几个值得借鉴的项目
2010-07-01 10:19 1729Flex的几个值得借鉴的项目 1、Merapi 经过近 ... -
台式电脑使用详情
2010-06-29 13:07 807台式电脑使用详情 联想启天 M5650 配置:AMD RS76 ...
相关推荐
Ajax struts2 xml flex Ajax struts2 xml flex Ajax struts2 xml flex Ajax struts2 xml flex Ajax struts2 xml flex Ajax struts2 xml flex
一个很好的flex与struts2整合过程
flex与 struts2与 hibernate与spring集成实例项目
用户信息管理系统。为flex+struts2 开发的工程代码 。
flex+struts教程 flex+struts教程
flex与+struts2+hibernate+spring集成实例项目,源码奉献,物有所值
这个是一个完整的Flex与java通信的一个小例子,实现了增删改查功能,这只是一个小例子 有不妥当的地方希望能包涵。 涉及 技术:Flex+struts2+hibernate+mysql
NULL 博文链接:https://wuxiubing.iteye.com/blog/1354181
flex+struts整合flex+struts整合视频视频
是个很好的flex+Struts实例学习
flex and struts结合使用方法
lib1 flex+struts2+spring+ibatis jar 完整的jar 需要下载本人资源lib2
lib2 flex+struts2+spring+ibatis 完整的jar 需要下载我提供的资源lib1
使用flex+struts2+spring简单整合,前后台使用httpService通信,而且是分工程管理,使用了简单的封装,放到eclipse中即可运行。看好了,不是SSH,想弄的话自己再继续做,还什么东西都想拿现成的啊。
flex struts2 实现单文件、同名文件、多文件上传,具体分析参考blog相关内容。
绝对可以使用的flex+spring2.0+struts2.0+hibernate3.5 的集成开发环境。里面有演示用例. 不能运行找我. 我的邮箱flyinget@163.com 真诚的想用劳动换取一些分数 ----------------------------- 注意:**************...
Flex4+struts 登陆 HTTP方式 继承structs2,jar包已配置好,直接使用即可,Flex4http方式访问java服务,通过struts2
Flex4+struts 登陆 HTTP方式 继承structs2,jar包已配置好,直接使用即可,Flex4http方式访问java服务,通过struts2
Flex整合java(struts)分层开发