ajax post spring mvc controller返回http 404

时间:2016-03-31 15:18:15

标签: ajax spring post model-view-controller http-status-code-404

我正在从弹簧mvc控制器发送一些用户信息(json对象),我可以通过http get请求获得正确的信息,但是当我发送ajax post请求时出现404错误,可以你告诉我哪里错了,任何建议都会受到高度赞赏!

   $.ajax({ data:JSON.stringify(item),
       type: "POST",
       contentType: "application/json",
       url: "/idm/rest",

        success: function(response, textStatus){
            item.id = response.id;
            if (success_callback != null)
            {
                 success_callback(response, textStatus);
            }
            result = response; 
        },
        error: function(XMLHttpRequest, textStatus, errorThrown){
            //this;   
            if (error_callback != null)
            {
                 error_callback(XMLHttpRequest, textStatus, errorThrown);
            }
            result = null;
        }
    });

2)spring mvc controller:

@RestController  
@RequestMapping("/user")
public class JxUserController {
@Autowired 
@Qualifier(value="appservice")
JxAppService svc;

@RequestMapping(value = "/{id}", method = RequestMethod.GET, produces={ "application/json"})
public JxUserEx find(@PathVariable("id") Integer id) {
    return svc.newUserService().findById(id);
}  

@RequestMapping(value = "", method = RequestMethod.GET)
public @ResponseBody List<JxUserEx> find(JxQuerySYST0011 querysyst0011) {
    com.opencenter.idm.service.user.JxUserService users = svc.newUserService();
    return users.find(querysyst0011);
}

@RequestMapping(value = "/meta", method = RequestMethod.GET)
public JxQueryMetadata findTotal() {
    return svc.newUserService().count();
} 

@RequestMapping(value= "", method=RequestMethod.POST) 
public @ResponseBody JxUserEx create(@RequestBody JxUserEx syst0011) {
    com.opencenter.idm.service.user.JxUserService users =   svc.newUserService();
    return users.create(syst0011);
}

ajax post request and the error messages spring mvc controller

0 个答案:

没有答案