mardi 14 avril 2015

POST request in Spring MVC not work after migration from 3.2 to 4.1

I send POST request



$.ajax({
type: "POST",
url: "/common/ajax/advert/",
data: data,
dataType: "json",
contentType: "application/json",
success: function(r){}
});


to controller



@Controller
@RequestMapping(value = "/common/ajax/advert")
public class Controller {

@RequestMapping(value="/", method=RequestMethod.POST)
@ResponseBody
public Map<String,Object> adsSearch(@RequestBody Map<String,Object> data){

Map<String,Object> result = new HashMap<String,Object>();
List<Advert> ads = advSrv.getAds(data);

result.put("obj", ads);
return result;
}


and return 404 error, but in spring 3.2 this work fine.


Controllers with RequestMethod.GET work correct in old and new version.


Please help me to fix it.


UPD.1 I tried to create a @RestController class (Spring 4.1) with RequestMethod.POST - and it did not work too.


UPD.2 In log Spring mapped this methods properly, but post request not handled (unlike get requests, they works fine).


Aucun commentaire:

Enregistrer un commentaire