设置session过期时间com.alibaba fastjson1.2.78
后台代码修改30
//验证旧密码,session中有用户的密码 public void pwdmodify(HttpServletRequest req, HttpServletResponse resp){ //从session里面拿ID; Object o = req.getSession().getAttribute(Constants.USER_SESSION); String oldpassword = req.getParameter("oldpassword"); //万能的map HashMapresultMap = new HashMap (); if (o==null){//session失效了,session过期了 resultMap.put("result","sessionerror"); }else if(StringUtils.isNullOrEmpty(oldpassword)){//输入密码为空 resultMap.put("result","error"); }else { String userPassword = ((User) o).getUserPassword();//session中用户的密码 if (oldpassword.equals(userPassword)){ resultMap.put("result","true"); }else{ resultMap.put("result","false"); } } resp.setContentType("application/json"); try { PrintWriter writer = resp.getWriter(); //JSONAray阿里巴巴的工具类,转换格式 writer.write(JSONArray.toJSONString(resultMap)); writer.flush(); writer.close(); } catch (IOException e) { e.printStackTrace(); } } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)