JeecgBoot 动态路由配置带参路由

1、官网写法:

带参数路由菜单 · JeecgBoot 开发文档 · 看云

2、个人写法

备注:因菜单较多,90%重复,新增、编辑不同

1.创建菜单(菜单路径跟隐藏菜单的前端组件地址一样)

 菜单路径/Res/1,其中这个1为随机数(可以根据个人定义)

 2、新增一个隐藏路由

/Res/:resType: (resType为变量)

 

 3、怎么拿到这个菜单路径

created () {
    this.initByPath()
  },
  watch: {
    '$route.path' (newVal, oldVal) {
      if (newVal !== oldVal) {
        this.activeObj = {}
        this.initByPath()
      }
    }
  },
  methods: {
    initByPath () {
      let that = this;
      let routeParams = this.$route.params
//routeParams.resType  为变量,拿到这个值,就可以判断是那个菜单
      if (routeParams && routeParams.resType) that.curType = routeParams.resType
      console.log('----------------------更换ResouceTypeId:',routeParams);
    },

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
JeecgBoot中,使用Shiro进行权限控制和路由控制,配置接口需要以下步骤: 1. 在Shiro配置文件中配置过滤器链:Shiro的过滤器链决定了请求的处理流程,需要在Shiro配置文件中配置过滤器链。可以使用Shiro提供的过滤器来实现不同的权限控制。 2. 配置接口权限:在Shiro配置文件中,可以使用Shiro提供的注解来配置接口的访问权限。例如,@RequiresPermissions注解可以限制只有具有指定权限的用户才能访问该接口。 3. 配置路由JeecgBoot使用Shiro进行路由控制,需要在Shiro配置文件中配置路由信息。可以使用Shiro提供的PathMatchingFilter来实现路由控制。 下面是一个简单的Shiro配置示例,用于控制/user接口的访问权限: ```xml <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean"> <property name="securityManager" ref="securityManager"/> <property name="loginUrl" value="/login"/> <property name="successUrl" value="/index"/> <property name="unauthorizedUrl" value="/403"/> <property name="filterChainDefinitions"> <value> /login = anon /** = authc </value> </property> </bean> <bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager"> <property name="realm" ref="userRealm"/> </bean> <bean id="userRealm" class="com.jeecg.boot.modules.user.realm.UserRealm"> <property name="credentialsMatcher" ref="hashedCredentialsMatcher"/> </bean> <bean id="hashedCredentialsMatcher" class="org.apache.shiro.authc.credential.HashedCredentialsMatcher"> <property name="hashAlgorithmName" value="md5"/> <property name="hashIterations" value="2"/> </bean> <bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/> <bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" depends-on="lifecycleBeanPostProcessor"> <property name="proxyTargetClass" value="true"/> </bean> <bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor"> <property name="securityManager" ref="securityManager"/> </bean> <bean id="sessionDAO" class="org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO"/> <bean id="sessionManager" class="org.apache.shiro.web.session.mgt.DefaultWebSessionManager"> <property name="sessionDAO" ref="sessionDAO"/> </bean> ``` 在这个示例中,/login接口允许匿名访问,其他接口需要进行身份认证。可以看到,在filterChainDefinitions中使用了/** = authc的配置,表示所有接口都需要进行身份认证。另外,可以在UserRealm中实现自定义的身份验证逻辑和授权逻辑。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

My&Liu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值