spring mvc3.0中的$ .getJSON问题

时间:2010-08-04 05:50:24

标签: jquery

我有以下javascript函数,我在提交按钮上点击....

function checkUser()       {           var uname = $('#username')。val();        var pword = $('#password')。val();        警报(UNAME);        警报(PWORD);

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

我正在使用spring mvc 3.0 .....以下是我使用的控制器...

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 公共类LoginController {  @RequestMapping( “/ login.html的”)  public @ResponseBody String getLoginStatus(@RequestParam(“username”)String username,@ RequestParam(“password”)String password)  {   System.out.println(“\ n \ nin登录控制器\ n \ n”);   if(username ==“apoorvabade”& password ==“apoorva123”)   {    返回“登录成功!!!”;   }   其他   {    返回“登录失败”;   }  } }

当我点击提交按钮时,不会调用与/login.html操作对应的功能....我正在使用DispatcherServlet将请求映射到以下内容....

这是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教程项目     弹簧       org.springframework.web.servlet.DispatcherServlet           1  

  弹簧   *。html的  

  的index.jsp  

有人可以告诉我这个问题吗?

1 个答案:

答案 0 :(得分:0)

它可能与您的提交功能有关。你没有表现出来。我在我的页面上运行了你的功能。 checkUser很高兴。

相关问题