package com.izouma.awesomeadmin.web; import org.apache.shiro.SecurityUtils; import org.apache.shiro.authz.annotation.RequiresRoles; import org.apache.shiro.subject.Subject; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; /** * 首页 * Created by xiong on 2016/10/26. */ @Controller public class MainController { // @RequestMapping(value = "/index", method = RequestMethod.GET) // @ResponseBody // public ModelAndView home() { // return new ModelAndView("redirect:/admin"); // } @RequestMapping("/index") public ModelAndView index(HttpServletRequest request) { return new ModelAndView("html/admin.html"); } @RequestMapping("/") public ModelAndView autoIndex(HttpServletRequest request) { return new ModelAndView("html/admin.html"); } @RequestMapping("/admin") public ModelAndView admin(HttpServletRequest request) { Subject subject = SecurityUtils.getSubject(); if (subject.hasRole("admin")) { return new ModelAndView("html/admin.html"); } else { return new ModelAndView("redirect:/loginAdmin"); } } @RequestMapping("/home") public ModelAndView home(HttpServletRequest request) { return new ModelAndView("html/admin.html"); } @RequestMapping("/loginAdmin") public ModelAndView loginAdmin(HttpServletRequest request) { return new ModelAndView("html/loginAdmin.html"); } }