2010-08-04 82 views
1

我有以下的javascript函數我稱之爲提交按鈕點擊....

功能checkUser(){ 變種 UNAME = $( '#用戶名' ).VAL(); var(p)= $('#password')。val(); alert(uname); alert(pword);

 $.getJSON("login.html",{username: uname, password: pword}, 
       function(message){ 
    alert(message); 
      }); 
    } 

我使用Spring MVC的3.0 .....下面是我用的控制器......

包com.web.controller;

import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody;

@Controller 公共類的LoginController { @RequestMapping( 「/ login.html的」) 公共字符串@ResponseBody getLoginStatus(@RequestParam( 「用​​戶名」)字符串的用戶名,@RequestParam( 「密碼」)字符串密碼) System.out.println(「\ n \ nin login controller \ n \ n」); if(username ==「apoorvabade」& password ==「apoorva123」) { return「Login successful !!!」; } else { return「登錄失敗」; }} }

當我提交按鈕點擊,相當於/login.html動作的功能則不會調用....我使用的DispatcherServlet的請求以下地圖... 。

這裏是彈簧servlet.xml中

http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd「>

/WEB-INF/JSP/ .JSP

的web.xml:

春阿賈克斯教程項目 彈簧 org.springframework.web.servlet.DispatcherServlet

彈簧 *。HTML

的index.jsp

可有人告訴我這個問題好嗎?

+0

對不起charatcter限制已經超過了...所以我會individuaaly後我的文件.... 的index.jsp: \t \t功能checkUser() \t \t { \t \t VAR UNAME = $('#用戶名「)VAL(); val(); var(p)= $('#password')。 \t \t \t alert(uname); \t \t \t alert(pword); \t \t \t \t \t \t \t \t $ .getJSON( 「login.hml」,{用戶名:UNAME,密碼:PWORD}, \t \t功能(消息){ \t \t \t \t \t \t \t警報(消息); \t \t}); \t \t} – apoorvabade 2010-08-04 06:14:28

回答

0

它可能與您的提交功能有關。你沒有表現出來。我在你的頁面上運行你的功能。 checkUser是很好去。