我学习Shiro
一步一步用@ BalusC的article,是没有问题的,直到我把它变成基于形式的认证为fifth part of the article说过。阿帕奇四郎不重定向我在JSF
我的确如文章所述,但是shiro没有将我重定向到登录页面,而是每当我运行我的web应用程序时,它总是显示index.xhtml
。
这是我的代码,我不知道我错过了什么。
web.xml中:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<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>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
</web-app>
shiro.ini:
[main]
authc.loginUrl = /login.xhtml
[users]
admin = password
[urls]
/login.xhtml = authc
/app/** = authc
应该有我重定向到login.xhtml
,不应该吗?
任何想法?提前致谢。
我试过这个,但是当我运行web应用程序时它仍然显示'index.xhtml'。 – nosnhoj
浏览器中显示的index.xhtml的实际url是/index.xhtml吗? – Wouter
我发现如果我输入'http:// localhost:8080/shiroPrac1/index.xhtml'而不是'http:// localhost:8080/shiroPrac1 /',它会重定向到'http:// localhost:8080/shiroPrac1/login.xhtml',但是,有什么问题吗?它不应该显示'index.xhtml',因为我没有登录。 – nosnhoj