Nach erfolgreicher Anmeldung leitet es nicht zu "index.php" um. Es leitet die gleiche Seite um, die "login.php" ist. Ist etwas mit meiner Seite spring-security.xml nicht in Ordnung?Spring Sicherheitsumleitung nach dem Login
Nebenbei, wenn ich die Anwendung ausführen, leitet es mich zu "login.php" um, was gut ist. Aber es zeigt nicht Hauptbestandteile, sondern HTML-Komponenten. Nachdem ich mich erfolgreich angemeldet habe, leitet es die gleiche Seite um, aber dieses Mal zeigt es Primefaces-Komponenten anstelle von HTML-Komponenten.
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<http auto-config="true" use-expressions="true">
<intercept-url pattern="/pages/login.xhtml*" access="permitAll"/>
<intercept-url pattern="/**" access="hasRole('admin')" />
<form-login login-page='/pages/login.xhtml' default-target-url="/pages/index.xhtml"
authentication-failure-url="/pages/login.xhtml"/>
<logout logout-success-url="/pages/logout.xhtml" />
</http>
<!--Authentication Manager Details -->
<authentication-manager alias="authenticationManager">
<authentication-provider user-service-ref="customUserDetailsService">
<!-- <password-encoder hash="md5"/>-->
</authentication-provider>
</authentication-manager>
meine web.xml
<welcome-file-list>
<welcome-file>pages/index.xhtml</welcome-file>
</welcome-file-list>
Anmeldungsseite
<p:outputPanel id="loginOutputPanelId" style="border: navy">
<p:panelGrid id="loginInformationPanel" columns="2">
<h:outputText value="Username: "/>
<p:inputText value="#{loginController.userName}"/>
<h:outputText value="Password: "/>
<p:inputText value="#{loginController.password}"/>
</p:panelGrid>
<p:commandButton value="Login" actionListener="#{loginController.login()}"/>
</p:outputPanel>
meine loginController.login() Methode gibt "index" String und meine faces.config;
<navigation-rule>
<from-view-id>/pages/login.xhtml</from-view-id>
<navigation-case>
<from-outcome>index</from-outcome>
<to-view-id>/pages/index.xhtml</to-view-id>
<redirect />
</navigation-case>
</navigation-rule>
EDIT: ohne Komponente läuft es ohne Probleme. Wenn ich Formular-Login hinzufüge, heißt es "Die Webseite unter http://localhost:8080/myApplication/pages/login.xhtml
hat zu viele Redirects geführt".
<http auto-config='true' use-expressions="true">
<intercept-url pattern="/**" access="hasRole('admin')" />
<logout logout-success-url="/pages/logout.xhtml" />
<form-login login-page="/pages/login.xhtml"
login-processing-url="/j_spring_security_check"
default-target-url="/pages/index.xhtml"
authentication-failure-url="/pages/login.xhtml"/>
</http>
Meine Login-Seite
<p:outputPanel id="loginOutputPanelId" style="border: navy">
<p:panelGrid id="loginInformationPanel" columns="2">
<h:outputText value="Kullanıcı Adı: "/>
<p:inputText id="j_username" required="true" value="#{loginController.userName}"/>
<h:outputText value="Şifre: "/>
<p:inputText id="j_password" required="true" value="#{loginController.password}"/>
</p:panelGrid>
<p:commandButton id="login" type="submit" ajax="false" value="Login" actionListener="#{loginController.login()}"/>
</p:outputPanel>
Mein neues loginController.login() -Methode;
ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
RequestDispatcher dispatcher = ((ServletRequest) context.getRequest())
.getRequestDispatcher("/j_spring_security_check");
dispatcher.forward((ServletRequest) context.getRequest(),
(ServletResponse) context.getResponse());
FacesContext.getCurrentInstance().responseComplete();
noch gleich. Es ändert nichts. –
Wie lautet die erste URL, die Sie anrufen? Rufen Sie direkt die Login-Seite an oder rufen Sie eine andere gesicherte URL an? – baraber
index.xhtml ist meine Willkommensdatei, die in "web.xml" definiert ist. Ich verstehe nicht, was du meinst. Es gibt die Login-Seite = '/ pages/login.xhtml' in der Datei spring-security.xml und die Spring-Sicherheit ruft zuerst login.xhtml auf. nachdem ich die Zeile "always-use-default-target =" true "hinzugefügt habe, wird nun keine Seite umgeleitet. Es bleibt auf der login.xhtml Seite. Dann schreibe ich die Indexadresse manuell in die Adressleiste des Browsers. –