当我从我的角度应用程序执行resquest时,我的servlet正确地重新提供了请求数据,但是当我尝试从我的servlet响应我的角度时,它并没有重新调整任何内容。
我的要求
$.post({
url:'/LegoRepository/CoreServlet',
data:{
angular:"a"
},
//type:'post',
cache:false,
success:function(responseText){
console.log("Credentials" + responseText);
},
error:function(){
console.log('Ajax Error');
}
});
我的servlet
response.setHeader("Content-Type", "application/json; UTF-8");
System.out.println(request.getParameter("name"));
response.setContentType("application/json");
response.setCharacterEncoding("utf-8");
response.setHeader("Access-Control-Allow-Origin", "*");
PrintWriter out = response.getWriter();
JSONObject json = new JSONObject();
try {
json.put("Name", "ManojSarnaik");
out.print(json.toString());
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
out.close();