0
私はstruts 1とjQueryの新機能です。 AJAXリクエストを使用してログインしたいと考えています。 これは私のjQueryのです:AJAXとStrutsのトラブル1
$.ajax({
url : "login.do",
type: "POST",
dataType: "text",
data:{
//Got the values before
"user" : user,
"pass": pass
},
success: function(result){
if(result === "OK")
window.location = "hello.do";
}
});
マイストラット-config設定:
<action path="/login" type="com.arquitectos.struts.LoginAction" parameter="login">
<forward name="OK" path="/"/>
</action>
マイLoginActionの:TBLファイルには、ちょうど今のクエリとか... を実行
public class LoginAction extends MappingDispatchAction{
private final String error = "ERROR";
private final String success = "OK";
private final String session = "SESSION";
private Usuario user = new Usuario();
public ActionForward login(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){
response.setContentType("text/texyt; charset = utf-8");
response.setHeader("Cache-Control", "no-cache");
try{
String u = request.getParameter("user");
String p = request.getParameter("pass");
if(u != null && p != null)
if(!(u.equals("")) && !(p.equals(""))){
user = TblLogin.Login(u, p);
if(user!=null)
return mapping.findForward(success);
}
}catch(Exception ex){
}
finally{
}
return mapping.findForward(null);
}
、私の疑問は、AJAXはどのようにして前進から「OK」を得るのだろうか?そのデータを取得してjQueryで比較する方法。