日期:2014-05-17 浏览次数:20689 次
@Controller
@RequestMapping( { "/entlogin.jtml" })
public class EntLoginController {
@Autowired
private EntSecurityService entSecurityService;
@Autowired
private EntMenuService entMenuService;
/**
* 返回void 则对应请求URL的.jtml变成.jsp
*
* @param model
*/
@RequestMapping(method = RequestMethod.GET)
public void loginGet(Model model) {
model.addAttribute("systemConfig", ConfigCacheDao.SystemConfigCache);
// add code
}
/**
* 后台登陆
*
* @return
*/
@RequestMapping(method = RequestMethod.POST)
public String login(Model model,
@ModelAttribute("user") EnterpriseUser enterpriseUser) {
model.addAttribute("systemConfig", ConfigCacheDao.SystemConfigCache);
boolean bl = entSecurityService.login(enterpriseUser);
if (!bl) {
model.addAttribute("msg", "用户名密码错误!");
return "entlogin";
} else{
EnterpriseUser u = entSecurityService.getCurrentUser();
List<EntMenu> menuList = entMenuService.getMenuByUser(u);
u.setMenuList(menuList);
return "entlogin.jtml";
}
}