为什么在我引入 Apache SHIRO 时 .XHTML 文件试图调用 .JSP 文件?

Why Is .XHTML file trying to call .JSP file when i introduce Apache SHIRO?

我有一个严重的问题。 我有一个带有框架 primefaces 的 JSF 项目。当我 运行 没有 Apache shiro 的 netbeans 项目时,它会将我重定向到 login.xhtml。但是一旦在 web.xml

中引入 shiro 配置
<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>

Neatbeans 将我重定向到 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>

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

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

authc.loginUrl = /login.xhtml

你的在上面的 post 中被注释掉了。