flex与struts2整合.docx

上传人:b****7 文档编号:10676230 上传时间:2023-02-22 格式:DOCX 页数:16 大小:396.39KB
下载 相关 举报
flex与struts2整合.docx_第1页
第1页 / 共16页
flex与struts2整合.docx_第2页
第2页 / 共16页
flex与struts2整合.docx_第3页
第3页 / 共16页
flex与struts2整合.docx_第4页
第4页 / 共16页
flex与struts2整合.docx_第5页
第5页 / 共16页
点击查看更多>>
下载资源
资源描述

flex与struts2整合.docx

《flex与struts2整合.docx》由会员分享,可在线阅读,更多相关《flex与struts2整合.docx(16页珍藏版)》请在冰豆网上搜索。

flex与struts2整合.docx

flex与struts2整合

Flex与struts2整合

1、首先我们建立一个web项目:

项目名为:

flexStruts2:

2、向项目中加入struts2 jar包,如下:

3、修改web.xml文件,加入struts2配置:

xmlversion="1.0"encoding="UTF-8"?

>

xmlns="

xmlns:

xsi="http:

//www.w3.org/2001/XMLSchema-instance"

xsi:

schemaLocation="

struts-cleanup

org.apache.struts2.dispatcher.ActionContextCleanUp

struts

org.apache.struts2.dispatcher.FilterDispatcher

 

struts

*.jsp

struts

*.action

index.jsp

4、加入flex jar包:

5、在项目WEB—INF目录下建文件夹“flex”,并加入:

messaging-config.xml、proxy-config.xml、remoting-config.xml、services-config.xml,如:

5、再次修改web.xml:

xmlversion="1.0"encoding="UTF-8"?

>

xmlns="

xmlns:

xsi="http:

//www.w3.org/2001/XMLSchema-instance"

xsi:

schemaLocation="

contextConfigLocation

/WEB-INF/classes/applicationContext.xml

BlazeDS

BlazeDSApplication

--HttpFlexSessionattributeandbindinglistenersupport-->

flex.messaging.HttpFlexSession

--MessageBrokerServlet-->

MessageBrokerServlet

flex.messaging.MessageBrokerServlet

services.configuration.file

/WEB-INF/flex/services-config.xml

1

ThisisthedescriptionofmyJ2EEcomponent

ThisisthedisplaynameofmyJ2EEcomponent

UploadServlet

com.action.info.UploadServlet

struts-cleanup

org.apache.struts2.dispatcher.ActionContextCleanUp

struts

org.apache.struts2.dispatcher.FilterDispatcher

 

struts

*.jsp

struts

*.action

index.jsp

6、用tomcat发布:

7、选中项目点右键,把flex整合进来:

8、选择下一步:

9、出现如图:

注意:

之前启动的tomcat一定不要关,否则点

的时候左上角会出现如下提示:

只有点击

出现

才是正确的。

这样我们就把flex整合进来了。

10、接下来可能会出现如下情况:

出现这个不要慌,选中项目右键:

再选择

如图:

选择对应的flex版本

点“Ok”呵呵。

解决问题!

10、接下来结合struts2做一个登录:

flexStruts2.xml代码如下:

xmlversion="1.0"encoding="utf-8"?

>

Applicationxmlns:

mx="layout="absolute"creationComplete="application.focusManager.setFocus(username);">

Script>

[CDATA[

import.navigateToURL;

importmx.controls.Alert;

importmx.rpc.events.ResultEvent;

privatefunctionloginHandle():

void{

if(username.text==""){

Alert.show("用户名不能为空!

");

return;

}

if(userpassword.text==""){

Alert.show("密码不能为空!

");

return;

}

loginAction.send();

}

privatefunctionloginResult(evt:

ResultEvent):

void{

if(evt.result.toString()=="success"){

Alert.show("登录成功!

");

}else{

Alert.show("用户名或密码错误!

");

}

}

]]>

Script>

Style>

Application{

font-size:

12px;

font-style:

normal;

font-weight:

normal;

}

Style>

HTTPServiceid="loginAction"result="loginResult(event)"resultFormat="text"

showBusyCursor="true"method="POST"url="../loginAction.action">

requestxmlns="">

{username.text}

{userpassword.text}

request>

HTTPService>

Panelwidth="412"height="256"layout="absolute"horizontalCenter="-41"verticalCenter="-19">

Labelx="31"y="49"text="用户名"width="72"/>

Labelx="31"y="96"text="密码"width="43"/>

TextInputx="82"y="47"id="username"/>

TextInputx="82"y="94"id="userpassword"displayAsPassword="true"/>

Buttonx="172"y="163"label="登录"click="loginHandle()"/>

Panel>

Application>

src下struts.xml:

xmlversion="1.0"encoding="UTF-8"?

>

DOCTYPEstrutsPUBLIC

"-//ApacheSoftwareFoundation//DTDStrutsConfiguration2.0//EN"

"http:

//struts.apache.org/dtds/struts-2.0.dtd">

写一个action类:

LoginAction.java

packagecom.action;

importjavax.servlet.http.HttpServletResponse;

importorg.apache.struts2.ServletActionContext;

importcom.opensymphony.xwork2.ActionSupport;

publicclassLoginActionextendsActionSupport{

privateStringusername;

privateStringuserpassword;

publicStringexecute()throwsException{

HttpServletResponseresponse=ServletActionContext.getResponse();

response.getWriter().write("success");

System.out.println("用户名:

"+username+"密码:

"+userpassword);

returnnull;

}

publicStringgetUsername(){

returnusername;

}

publicvoidsetUsername(Stringusername){

this.username=username;

}

publicStringgetUserpassword(){

returnuserpassword;

}

publicvoidsetUserpassword(Stringuserpassword){

this.userpassword=userpassword;

}

}

 

如上基本上完成.

选中flexStruts2.mxml右键运行看看效果吧!

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工程科技 > 能源化工

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1