I am creating a spring mvc3.0 application.... i have the jquery-1.3.2.js added to the project.... 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.RequestMap ping; import org.springframework.web.bind.annotation.RequestMet hod; import org.springframework.web.bind.annotation.RequestPar am; import org.springframework.web.bind.annotation.ResponseBo dy;
@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
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schem...ring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<context:component-scan base-package="com.web.controller" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.Intern alResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/jsp/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
</beans>
web.xml:
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Spring Ajax Tutorial Project</display-name>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
Can anybody tell me the problem please?
