MainController.java 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package com.izouma.awesomeadmin.web;
  2. import org.apache.shiro.SecurityUtils;
  3. import org.apache.shiro.authz.annotation.RequiresRoles;
  4. import org.apache.shiro.subject.Subject;
  5. import org.springframework.stereotype.Controller;
  6. import org.springframework.web.bind.annotation.PathVariable;
  7. import org.springframework.web.bind.annotation.RequestMapping;
  8. import org.springframework.web.bind.annotation.RequestMethod;
  9. import org.springframework.web.bind.annotation.ResponseBody;
  10. import org.springframework.web.servlet.ModelAndView;
  11. import javax.servlet.http.HttpServletRequest;
  12. /**
  13. * 首页
  14. * Created by xiong on 2016/10/26.
  15. */
  16. @Controller
  17. public class MainController {
  18. // @RequestMapping(value = "/index", method = RequestMethod.GET)
  19. // @ResponseBody
  20. // public ModelAndView home() {
  21. // return new ModelAndView("redirect:/admin");
  22. // }
  23. @RequestMapping("/index")
  24. public ModelAndView index(HttpServletRequest request) {
  25. return new ModelAndView("html/zouma.html");
  26. }
  27. @RequestMapping("/")
  28. public ModelAndView autoIndex(HttpServletRequest request) {
  29. return new ModelAndView("html/zouma.html");
  30. }
  31. @RequestMapping("/admin")
  32. public ModelAndView admin(HttpServletRequest request) {
  33. Subject subject = SecurityUtils.getSubject();
  34. if (subject.hasRole("admin")) {
  35. return new ModelAndView("html/admin.html");
  36. } else {
  37. return new ModelAndView("redirect:/loginAdmin");
  38. }
  39. }
  40. @RequestMapping("/loginAdmin")
  41. public ModelAndView loginAdmin(HttpServletRequest request) {
  42. return new ModelAndView("html/loginAdmin.html");
  43. }
  44. @RequestMapping("/phoneDemo")
  45. public ModelAndView phoneDemo(HttpServletRequest request) {
  46. return new ModelAndView("html/phoneDemo.html");
  47. }
  48. }