map){ map.put("msg","登出!"); map.put("url","/sell"); return new ModelAndView("co_springboot ">
赞
踩
前端直接使用Thymeleaf语法即可
ModelAndView是用来返回页面的,防止添加了@RestController
注解
@GetMapping("/seller/logout")
public ModelAndView logout(Map<String,Object> map){
map.put("msg","登出!");
map.put("url","/sell");
return new ModelAndView("common/success",map);
}
注意不要加@RestController
注解
@GetMapping("/index")
public Object index(HttpServletRequest request) {
//先获取principal,这个是通过MyRealm的认证方法rutuen的,进行了注入
Object principal = SecurityUtils.getSubject().getPrincipal();
AccountProfile user = (AccountProfile) principal;
//添加session
request.setAttribute("username",user.getUsername());
return "index";
}
@RequestMapping(value = "/")
public String index(Model model){
String students ="刘洋";
model.addAttribute("s",students)
return "index";
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。