tags:

views:

55

answers:

1

I have the following javascript function which i call on the submit button click....

function checkUser() { var uname=$('#username').val(); var pword=$('#password').val(); alert(uname); alert(pword);

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

i am using spring mvc 3.0..... Following is the controller that i use...

package 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 public class LoginController { @RequestMapping("/login.html") public @ResponseBody String getLoginStatus(@RequestParam("username") String username, @RequestParam("password") String password) { System.out.println("\n\nin login controller\n\n"); if(username=="apoorvabade" & password=="apoorva123") { return "Login successful!!!"; } else { return "Login failed"; } } }

when i click on the submit button, the function corresponding to the /login.html action is not invoked.... i am using the DispatcherServlet to map the requests to the following....

here is the spring-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:

Spring Ajax Tutorial Project spring org.springframework.web.servlet.DispatcherServlet 1

spring *.html

index.jsp

Can anybody tell me the problem please?

A: 

It probably has to do with your submit function. You didn't show that. I ran your function on my page. checkUser is good to go.

Gutzofter