2011-03-10 148 views
0

在我的客户端中,我使用ajax向Spring控制器发送请求。这最后可以拦截它,但是当我返回一个值时,我不能在我的客户端没有它。Spring-mvc和Ajax jquery:无法从服务器获得响应

客户端代码:

$.ajax({ 
      type: "GET", 
      data: {name : "name"}, 
      url: "/web/private/frontend/accueil/dateHistorique.html", 
      success: function(msg){ 
       alert("Hello"); 
      } 
     }); 

服务器端代码:

 @RequestMapping(value="/dateHistorique.html", method = RequestMethod.GET) 
public @ResponseBody Map<String, String> getAllowedDate(@RequestParam String name) { 
    System.out.println("***********************************" + name); 
    AllowedDates allowedDates = new AllowedDates("1","20"); 
    Map<String, String> responseMap = new HashMap<String, String>(); 
    responseMap.put("Name", "Marouane"); 
    return responseMap; 
} 

我能看见了放在服务器:* ** * *** *名称但始终没有回应。 日Thnx

+0

'/web/private/frontend/accueil/dateHistorique.html' 正在寻找像一个文件系统路径。确定你可以通过浏览器调用它? – schellmax 2011-03-10 14:20:32

+0

这只是一个映射:)它现在正在工作,我只需要返回一个可以转换为JSON的对象。怎么做 ? – 2011-03-10 14:27:00

+0

不知道春天,但发现这个:http://spring-json.sourceforge.net/(取自http://stackoverflow.com/questions/1601992/sp​​ring-3-json-with-mvc) – schellmax 2011-03-10 14:35:12

回答

0

应该添加Jackson到我的POM和<mvc:annotation-driven />到我的MVC-的servlet上下文

相关问题