初学flex,写个flex(通过URLLoader)与后台交互的例子,解决中午乱码的处理:


这是flex.jsp的代码:

<%...@ page contentType="text/html; charset=UTF-8" %>

<%...
String usr = java.net.URLDecoder.decode(request.getParameter("user"), "UTF-8");
System.out.println("取得传入的参数:"+usr);
String psw = java.net.URLDecoder.decode(request.getParameter("psw"), "UTF-8");
System.out.println("取得传入的参数:"+psw);
%>
<%=usr%>+<%=psw%>
这是login.mxml的代码:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" fontSize="12" xmlns:local="*">
<mx:TraceTarget/>
<mx:Style>
.lab{
fontWeight: "bold";
/*color: #FF0000;*/
fontSize: 15;
}
</mx:Style>
<mx:Script>
<
private function openHandler(event:Event):void {
trace("openHandler: " + event);
//this.focusManager.setFocus(loading);
btn_btn.enabled=false;
}

private function progressHandler(event:ProgressEvent):void {
trace("progressHandler loaded:" + event.bytesLoaded + " total: " + event.bytesTotal);
}

private function securityErrorHandler(event:SecurityErrorEvent):void {
trace("securityErrorHandler: " + event);
}

private function httpStatusHandler(event:HTTPStatusEvent):void {
trace("httpStatusHandler: " + event);
}

private function ioErrorHandler(event:IOErrorEvent):void {
trace("ioErrorHandler: " + event);
}
]]>
</mx:Script>
<mx:Panel title="欢迎登录WAP管理系统:" width="307" height="189" layout="absolute" verticalAlign="top" horizontalCenter="-10.5" verticalCenter="-9">
<mx:Label x="32" y="25" text="登录口令:" width="59"/>
<mx:TextInput id="user" x="99" y="23" width="147"/>
<mx:Label x="32" y="53" text="登录密码:" width="59"/>
<mx:TextInput id="psw" x="99" y="51" displayAsPassword="true" width="147"/>
<mx:ControlBar alpha="1">
<mx:Button id="btn_btn" x="58" y="92" label="确 定" click="this.doLogin();"/>
<mx:Button x="162" y="92" label="取 消"/>
<mx:Label x="0" y="129" text="Powered by Keren" textAlign="right"/>
</mx:ControlBar>
</mx:Panel>
</mx:Application>