我尝试在我的项目中使用 Apache Shiro 身份验证,但没有成功。我无法发现问题出在哪里。我只需要用户直接访问 /pages/principal/products.xhtml 页面,选择要购买的产品,然后重定向到 /purchase.xhtml 以完成购买,但在我的情况下,我尝试的所有请求都重定向到/login.xhtml 页面。有没有人有什么建议?下面的代码。谢谢!
shiro.ini
[main]
authc.loginUrl = /login.xhtml
authc.successUrl = /index.xhtml
[users]
admin@faces.com = adminfaces, admin
user@faces.com = user, customer
[roles]
admin = *
customer = purchases
[urls]
/index.xhtml = anon
/pages/principal/products = anon
/login.xhtml = authc
/javax.faces.resource/** = anon
/logout = logout
/pages/purchase/** = authc
/protected/** = authc, roles[admin]
web.xml
...
<listener>
<listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener
</listener-class>
</listener>
<filter>
<filter-name>ShiroFilter</filter-name>
<filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ShiroFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
...