@Controller
public class myViewController{
` `@RequestMapping("myMainPage") public void myMainPage(Model model){
` `model.addAttribute("logoImg", "site_logo.png");
` `}
}
@Around("execution(* com.gas..controller.*Controller.*(..))")
public Object checkAuth(ProceedingJoinPoint joinPoint) throws Throwable{
` `// this aspect is check "Auth Level" before view Controller running
` `// if "User Auth Level" is lower then return error page(new ModelAndView("error");)
` `//.... auth Level check
` `Object resultObject = null;
` `if(authLevel > 0){
` `resultObject = joinPoint.proceed();
` `} else {
` `//permission denied
` `resultObject = new ModelAndView("error");
` `}
}
我的期望是我应该看到一个错误页面,但是......它没有用(我可以看到 mainPage)
总是显示主页
为什么当返回类型为 void 时不起作用?
有效~~哈哈...但我不明白 void 和 modelAndView 的区别
帮助教我。
### i solved! -> change Controller source
```java
@Controller
public class myViewController{
` `@RequestMapping("myMainPage") public ModelAndView myMainPage(Model model){
` `model.addAttribute("logoImg", "site_logo.png");
` `return new ModelAndView("myMainPage");
` `}
}
成功了
dd