2
我在通过ajax
cal调用servlet
中检索会话属性时遇到问题。无法从ajax调用servlet检索会话属性
$('#homemainSearchField').submit(function(){
$.get("./CheckNoOfSearch",function(data){
checkLimitation(data);
});
});
在CheckNoOfSearch
servlet
我试图找回一些会话属性,但所有的会话属性为空,但它不是,我没有把它设置。
的servlet代码是
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
HttpSession session = request.getSession();
int noOfSearch = 0;
if (session.getAttribute("auth") != null && session.getAttribute("type") != null) {
System.out.println("Session found");
}
out.print(noOfSearch);
} finally {
out.close();
}
}
向我们展示您的servlet代码。你的问题在于servlet代码。您正确使用$ .get。 – Funkytown