HttpSession httpSession = ServletActionContext.getRequest().getSession(); httpSession.setAttribute("userName", member.getMemberName()); httpSession.setAttribute("userId", member.getMemberID()); httpSession.setAttribute("userAuthority", member.getMemberAuthority()); httpSession.setAttribute("userSex", member.getMemberSex()); httpSession.setAttribute("useDept", member.getDepartment().getDeptName()); responseText = "success";
以上是 登陆action中赋值
下面是 其他的action中取值,之间是不是还要写其他的代码?
HttpSession httpSession = ServletActionContext.getRequest().getSession(); String name=httpSession.getAttribute("userName").toString(); finance.setFinanceOperator(name); finance.setFinanceDate(enterStorehouse.getEnterTime()); finance.setFinanceMoney(enterStorehouse.getEnterNumber()*enterStorehouse.getEnterPrice()); finance.setFinanceType("支出"); finance.setFinanceRemark("商品入库,产品为:"+goods.getGoodsName()+"供应商为:"+supplier.getSupplierName()+"单价为:"+enterStorehouse.getEnterPrice()+"数量为:"+enterStorehouse.getEnterNumber()); financeService.save(finance);