java动态菜单显示实现,java – 为Spring MVC / AOP应用程序实现动态菜单

我希望为我的

Spring MVC应用程序实现动态可更改的菜单(无论何时添加带注释的方法或控制器).

我想要的是引入新的注释(@RequestMenuMapping),它将转到@Controller bean及其方法(就像@RequestMapping一样).

Heres是我想要的,User类,生成菜单之类的

Users

Index | List | Signup | Login

使用以下代码:

@Controller

@RequestMapping("user")

@RequestMenuMapping("Users")

public class User {

@RequestMapping("")

@RequestMenuMapping("Index")

public String index(/* no model here - just show almost static page (yet with JSP checks for authority)*/) {

return "user/index.tile";

}

@RequestMapping("list")

@RequestMenuMapping("List")

public String list(Model model) {

model.addAttribute("userList",/* get userlist from DAO/Service */);

return "user/list.tile";

}

@RequestMapping("signup")

@RequestMenuMapping("Signup")

public String signup(Model model) {

model.addAttribute("user",/* create new UserModel instance to be populated by user via html form */);

return "user/signup.tile";

}

@RequestMapping("login")

@RequestMenuMapping("Login")

public String login(Model model) {

model.addAttribute("userCreds",/* create new UserCreds instance to be populated via html form with login and pssword*/);

return "user/login.tile";

}

}

我认为Spring AOP可以帮助我使用@RequestMenuMapping注释切入方法,并通过@AfterReturning将代表网站菜单的内容添加到模型中.

但这提出了两个问题:

>如果在adviced方法中缺少(如.index()),我如何在@AfterReturning建议方法中获取Model实例?

>我如何获得所有方法(如在java反射方法中)和使用@RequestMenuMapping注释的类(如在java反射类中)以构建完整的菜单索引?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值