No such accessible method: addForwardConfig() on object异常

本文讨论了如何正确配置Struts框架中的动作映射,特别关注了将字符串类型更改为类类型的改进方法,以实现更高效的数据处理流程。通过实例演示,展示了从原始配置到优化配置的转变过程,旨在提升开发者的实践技能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<action-mappings>

   <action path="/login" className="struts.LoginAction" name="loginForm"
    input="index.jsp" validate="false">
    <forward name="ok" path="/ok.jsp"></forward>
   </action>

</action-mappings>

 

应该改为

<action-mappings>
   <action path="/login" type="struts.LoginAction" name="loginForm"
    input="index.jsp" validate="false">
    <forward name="ok" path="/ok.jsp"></forward>
   </action>

</action-mappings>

 

import router from './router' import store from './store' import { Message } from 'element-ui' import NProgress from 'nprogress' // progress bar import 'nprogress/nprogress.css' // progress bar style import { getToken } from '@/utils/auth' // get token from cookie import getPageTitle from '@/utils/get-page-title' NProgress.configure({ showSpinner: false }) // NProgress Configuration const whiteList = ['/login', '/auth-redirect'] // no redirect whitelist router.beforeEach(async(to, from, next) => { // start progress bar NProgress.start() // set page title document.title = getPageTitle(to.meta.title) // determine whether the user has logged in const hasToken = getToken() if (hasToken) { if (to.path === '/login') { // if is logged in, redirect to the home page next() NProgress.done() // hack: https://github.com/PanJiaChen/vue-element-admin/pull/2939 } else { // determine whether the user has obtained his permission roles through getInfo const hasRoles = store.getters.authorityList && store.getters.authorityList.length > 0 if (hasRoles) { next() } else { try { // get user info // note: roles must be a object array! such as: ['admin'] or ,['developer','editor'] const { authorityList } = await store.dispatch('user/getInfo') if (!authorityList || authorityList.length === 0) { Message.error('请先授权再登录') next('/login') NProgress.done() return } // generate accessible routes map based on roles const accessRoutes = await store.dispatch('permission/generateRoutes', authorityList) // dynamically add accessible routes router.addRoutes(accessRoutes) // hack method to ensure that addRoutes is complete // set the replace: true, so the navigation will not leave a history record next({ ...to, replace: true }) // next() } catch (error) { // remove token and go to login page to re-login await store.dispatch('user/resetToken') Message.error(error || 'Has Error') next(`/login?redirect=${to.path}`) NProgress.done() } } } } else { /* has no token*/ if (whiteList.indexOf(to.path) !== -1) { // in the free login whitelist, go directly next() } else { // other pages that do not have permission to access are redirected to the login page. next(`/login?redirect=${to.path}`) NProgress.done() } } }) router.afterEach(() => { // finish progress bar NProgress.done() }) 详细分析讲解上方路由守卫代码
最新发布
06-19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值