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.
here is my ajax call:
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.
@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>
<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. Add this code to your web.xml.
<servlet-mapping>
<servlet-name>Shop</servlet-name>
<url-pattern>/shop</url-pattern>
</servlet-mapping>
Hope this will resolve your problem
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.