我學習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