flex+jsp做的登陆,httpService传值时遇到点问题!
用flex+jsp做了个小型登陆的东西,用的是httpService中Post的方式传值。但是网络显示器显示找不到我的jsp源代码位置(http://localhost:8080/test/successed.jsp)。
检查了一下,代码位置应该没有问题的。不知道什么原因,求解释!附上代码!
flex:
- XML code
<?xml version="1.0" encoding="utf-8"?><s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"> <fx:Script> <![CDATA[ import mx.controls.Alert; import mx.rpc.events.ResultEvent; private function PostLoginHandler(event:ResultEvent):void { var sateLogin:String=event.result.toString(); var a:Array = sateLogin.split(","); if(a[0] == "admin"){//登入成功後,入使用者名 this.loginBox.visible=false; this.logoutBox.visible=true; this.Username.text=a[1]; }else{//登入失跳出警告框 Alert.show("登入失:\r\n再次密"); } } private function login_click(event:MouseEvent):void { var obj:Object = new Object(); obj.userID = this.userID.text; obj.userPW = this.userPW.text; this.loginService.send(obj); } ]]> </fx:Script> <fx:Declarations> <!-- 将非可视元素(例如服务、值对象)放在此处 --> <mx:HTTPService id="loginService" url="http://localhost:8080/test/successed.jsp" method="POST" resultFormat="object" result="PostLoginHandler(event)" /> </fx:Declarations> <mx:HBox id="loginBox"> <mx:Label text=":"/> <mx:TextInput id="userID"/> <mx:Label text="密:"/> <mx:TextInput id="userPW" displayAsPassword="true"/> <mx:Button label="送出" click="login_click(event);"/> </mx:HBox> <mx:VBox id="logoutBox" width="100%" height="100%" visible="false"> <mx:HBox width="100%"> <mx:Label id="Username" fontSize="12" /> <mx:Button label="登出 "/> </mx:HBox> </mx:VBox></s:Application>
jsp:
- JScript code
<%@ page contentType="text/html; charset=GB2312"%><%@ page import="java.io.*"%><%@ page import="java.util.*"%><%@ page import="java.sql.*"%><% out.println(request.getParameter("userID")); out.println(request.getParameter("userPW")); String Username=request.getParameter("userID"); String Password=request.getParameter("userPW"); if(Username=="admin" && Password=="admin") { out.println("Good!"); } %>
[解决办法]
代码有问题吧?
out.println("Good!");
这句的分号明显跟别的不一样