//管理员登录功能的请求(controller层) @RequestMapping("/loginForadministrator") public ModelAndView loginForadministrator(Administrator administrator, HttpSession session) { boolean flag = administrator_service.loginForadministrator(administrator); session.setAttribute("user1",);//用session取得登陆时输入的username值 ModelAndView mv = new ModelAndView(); if (flag) { mv.setViewName("admin_ad"); } else { mv.setViewName("error"); } return mv; }
//jsp页面显示session
<%--登陆后显示管理员姓名--%> <b class="text-black">欢迎您</b> <a class="text-black"> <%=session.getAttribute("user1")%> </a> </span></a>
//管理员登录功能(ServiceImpl.java)
public boolean loginForadministrator(Administrator administrator) { Administrator administrator1 = administrator_Mapper.loginForadministrator(administrator); if (administrator1 != null) { return true; } else { return false; } }
//Mapper接口
Administrator loginForadministrator(Administrator administrator);
//Service接口
boolean loginForadministrator(Administrator administrator);
//xml文件
<!--登录功能之管理员登录--> <select id="loginForadministrator" resultType="Administrator"> select * from school_hdu01.administrator where username = #{username} and password = #{password}
希望帮解决下,这样的情况怎么把登录界面输入的username值保存在sessionz