javascript - AJAX post request does not find Spring MVC controller, returns 404 -
i new spring mvc framework, , trying getting hands dirty. here ajax call:
$.ajax("/spn/list/next"...
here 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 public class listnexpagecontroller { private static final string next_page_leads_url="/list/next"; @requestmapping(value=next_page_leads_url,method=requestmethod.post) @responsebody public void getnextpage(@requestparam(value="pagekey",required=false)string pagekeystring,@requestparam(value="category",required=false)string category){ log.info("url hit, yay!"); }
}
the post call returns 404 error, implying can't find controller. can please hint @ might doing wrong? note sending array of objects parameter in post call.
here complete ajax call:
$.ajax("/spn/list/next", { method: 'post', params: ajax_data });
your controller method mapped "/list/next" ajax method calls "/spn/list/next". can try add context path (if it's jsp):
$.ajax("${pagecontext.request.contextpath}" + "/list/next", { method: 'post', params: ajax_data });
Comments
Post a Comment