为什么当我介绍ApacheShiro时.xhtml文件试图调用.jsp文件?

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (1)
  • 关注 (0)
  • 查看 (52)

我有一个JSF项目,它具有框架素数面(FramePrimeFaces)。当我在NetBeans中运行该项目时,没有Apacheshiro,它会将我重定向到login.xhtml。

<listener>
    <listenerclass>
        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>

Neatbean将我重定向到login.jsp。这是我的shiro.ini文件

[main]
#le chemin de la classe "FacesAjaxAwareUserFilter" et celuii de la page qui va s'afficher si l'uthentification ne marche pas et la page qui s'affichera si ca marche
user = com.soulsofts.atmosphere.web.utils.shiro.FacesAjaxAwareUserFilter
#authc.loginUrl = /login.xhtml
#authc.successUrl = /index.xhtml

#;l'id de de la form du login et les different champs 
authc.usernameParam = login:username
authc.passwordParam = login:password
authc.rememberMeParam = login:rememberMe

#;le nom de la classe qui contien les configurations
entityRealm =  com.soulsofts.atmosphere.web.utils.shiro.EntityRealm

#authentif = com.soulsofts.atmosphere.core.entities.User
#;cette partie contient le nom des utilisateur qui ne seront pas verifier l'or de l'authentification
[users]
njjjjj=njjjjj

#;permet de definir les URL qui on besoin d'athentification avant de pouvoir y acceder
#;anon= pour dire que cette page n'aura pas besoin d'authentification
#;authc=pour dire que cette page en aura besoin
[urls]
/javax.faces.resource/** = anon
/resources/** = anon
/WEB-INF/** = anon
/login.xhtml = anon
/access-denied.xhtml = anon
/error.xhtml = anon
/404.xhtml = anon
/empty-page.xhtml = anon
/access-denied.xhtml = anon
/** = authc

这里是web.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <welcome-file-list>
        <welcome-file>index.xhtml</welcome-file>
    </welcome-file-list>
    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>server</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Production</param-value>
    </context-param>
    <context-param>
        <param-name>primefaces.THEME</param-name>
        <param-value>verona-turquoise</param-value>
    </context-param>
    <context-param>
        <param-name>primefaces.FONT_AWESOME</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
        <param-value>/WEB-INF/primefaces-verona.taglib.xml</param-value>
    </context-param>
    <filter>
        <filter-name>Character Encoding Filter</filter-name>
        <filter-class>com.soulsofts.atmosphere.web.veronaComponent.CharacterEncodingFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>Character Encoding Filter</filter-name>
        <servlet-name>Faces Servlet</servlet-name>
    </filter-mapping>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>
    <mime-mapping>
        <extension>ttf</extension>
        <mime-type>application/font-sfnt</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>woff</extension>
        <mime-type>application/font-woff</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>woff2</extension>
        <mime-type>application/font-woff2</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>eot</extension>
        <mime-type>application/vnd.ms-fontobject</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>eot?#iefix</extension>
        <mime-type>application/vnd.ms-fontobject</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>svg</extension>
        <mime-type>image/svg+xml</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>svg#exosemibold</extension>
        <mime-type>image/svg+xml</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>svg#exobolditalic</extension>
        <mime-type>image/svg+xml</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>svg#exomedium</extension>
        <mime-type>image/svg+xml</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>svg#exoregular</extension>
        <mime-type>image/svg+xml</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>svg#fontawesomeregular</extension>
        <mime-type>image/svg+xml</mime-type>
    </mime-mapping>
    <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>
    <listener>
        <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
    </listener>
</web-app>

你能帮我解决这个问题吗?

提问于
用户回答回答于

如果没有指定,URL login.jsp是Shiro默认页面。你必须像下面这样使用authc.loginUrl.。

authc.loginUrl = /login.xhtml

扫码关注云+社区

领取腾讯云代金券