[英]ajax request not received by Servlet
I am trying to send a POST AJAX request to reload data in index.xhtml But the request is never received up by the servlet. 我正在尝试发送POST AJAX请求以将数据重新加载到index.xhtml中,但是servlet从未收到过该请求。
here is my ajax call: 这是我的ajax电话:
function changeStep(sub_step_id)
{
console.log('ok');
$.ajax({
type:"POST",
headers: {
'Authorization':'Basic xxxxxxxxxxxxx',
'X_CSRF_TOKEN':'xxxxxxxxxxxxxxxxxxxx',
'dataType': 'json',
'Content-Type':'application/json'
},
data:{"sub_step_id":sub_step_id},
url:'Shop',
success : function(data){
console.log("sucess");
location.href = url;
},
error:function(e){
// Error
}
});
}
In my servlet both doGET and doPOST method are implemented but none of them are being called when the request arrives to my server. 在我的servlet中,都实现了doGET和doPOST方法,但是当请求到达我的服务器时都没有调用它们。
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
process(request,response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
process(request,response);
}
My Servlet is mapped in web.xml here is an extract of it: 我的Servlet映射在web.xml中,下面是它的摘录:
<servlet>
<servlet-name>Shop</servlet-name>
<servlet-class>com.kino.front.homeManager</servlet-class>
</servlet>
here the request call 这里的请求电话
This is because you haven't mapped the url for that servlet. 这是因为您尚未映射该servlet的URL。 Add this code to your web.xml.
将此代码添加到您的web.xml。
<servlet-mapping>
<servlet-name>Shop</servlet-name>
<url-pattern>/shop</url-pattern>
</servlet-mapping>
Hope this will resolve your problem 希望这能解决您的问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.