【问题标题】:apache shiro and Spring mvcapache shiro 和 Spring mvc
【发布时间】:2015-09-18 23:13:56
【问题描述】:

我在使用 angularjs 的 apache shiro 和 spring mvc 时遇到了问题。

当我访问 angularjs 页面 http://localhost:8080/app 时出现 404 错误。在 app 文件夹内有一个 index.html,它应该是 angularjs 应用程序的开始。

下面是shiro.ini

# INI configuration is very powerful and flexible, while still remaining succinct.
# Please http://shiro.apache.org/configuration.html and
# http://shiro.apache.org/web.html for more.

[main]

authc.loginUrl = /login.html
authc.usernameParam = username
authc.passwordParam = password
authc.rememberMeParam = rememberMe
authc.successUrl = /app


logout.redirectUrl = /logout.html

# use in-memory caching to reduce the number of runtime lookups against the data source.
cacheManager = org.apache.shiro.cache.MemoryConstrainedCacheManager
securityManager.cacheManager = $cacheManager

# configure hashed password authentication
credentialsMatcher = org.apache.shiro.authc.credential.Sha512CredentialsMatcher
credentialsMatcher.storedCredentialsHexEncoded = false
credentialsMatcher.hashIterations = 1

# configure a realm to connect to the data source
daRealm = com.example.security.myRealm
daRealm.credentialsMatcher = $credentialsMatcher
securityManager.realms = $myRealm

[urls]

/app/** = anon

/favicon.ico = anon
/css/home.css = anon
/images/** = anon
/ = anon
/index.html = anon

/rest/** = anon

/logout = logout

/login.html = authc

/** = authc

【问题讨论】:

    标签: angularjs spring spring-mvc shiro


    【解决方案1】:

    我认为你应该使用

    authc.successUrl = /index.html
    

    如果app下有app目录则

    authc.successUrl = /app/index.html
    

    另外,作为您的代码,我无法弄清楚您在保护什么,因为只有一个属性与 authc 相关

    /app/** = anon
    /favicon.ico = anon
    /css/home.css = anon
    /images/** = anon
    / = anon
    /index.html = anon
    /rest/** = anon
    /logout = logout
    /login.html = authc
    

    【讨论】:

      猜你喜欢
      • 2012-03-08
      • 2014-08-31
      • 2016-07-30
      • 2011-07-20
      • 2017-11-24
      • 2016-12-17
      • 2017-01-05
      • 2018-09-03
      • 2015-10-03
      相关资源
      最近更新 更多