第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

Spring Security 自定義登錄處理 URL 始終重定向到故障處理程序

Spring Security 自定義登錄處理 URL 始終重定向到故障處理程序

哆啦的時(shí)光機(jī) 2022-06-15 15:37:58
我正在開(kāi)發(fā)一個(gè)帶有基于注釋的配置的 spring 安全代碼。但是,在從登錄頁(yè)面點(diǎn)擊WebSecurityConfig類(擴(kuò)展WebSecurityConfigurerAdapter )的配置方法中定義的登錄處理 url 后,即使提供了正確的用戶名和密碼,它也總是重定向到httpSecurity 的.failureHandler()方法而不是.successHandler ( ) 方法。下面是WebSecurityConfig類的configure方法和configureGlobal方法。@Overrideprotected void configure(HttpSecurity httpSecurity) throws Exception {    httpSecurity    .authorizeRequests()    .antMatchers("/login.success").access("hasRole('ROLE_USER')")            .and()            .formLogin()            .loginPage("/login.home")            .usernameParameter("username")            .passwordParameter("password")            .loginProcessingUrl("/login.do")            .successHandler(applicationLoginSuccessHandler)            .failureHandler(applicationLoginFailureHandler)            .and()            .logout()            .logoutRequestMatcher(new AntPathRequestMatcher("/logout"));}@Autowiredpublic void configureGlobal(AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception {    authenticationManagerBuilder.inMemoryAuthentication().withUser("user").password("pass").roles("USER");}   這是login.jsp的片段<c:url value="login.do" var="loginUrl"/><form action="${loginUrl}" method="POST">             <c:if test="${param.error != null}">                  <p>              Invalid username and password.          </p>      </c:if>      <c:if test="${param.logout != null}">                 <p>              You have been logged out.          </p>      </c:if>      <p>          <label for="username">Username</label>          <input type="text" id="username" name="username"/>          </p>      <p>          <label for="password">Password</label>          <input type="password" id="password" name="password"/>          </p>      <input type="hidden"                                  name="${_csrf.parameterName}"          value="${_csrf.token}"/>      <button type="submit" class="btn">Log in</button>  </form>  我錯(cuò)過(guò)了什么?我正在使用彈簧安全 5.1.2.release
查看完整描述

2 回答

?
繁星點(diǎn)點(diǎn)滴滴

TA貢獻(xiàn)1803條經(jīng)驗(yàn) 獲得超3個(gè)贊

它一直在工作。實(shí)際上,我為此錯(cuò)過(guò)了密碼編碼器。雖然我給了一個(gè)重定向到成功頁(yè)面。



查看完整回答
反對(duì) 回復(fù) 2022-06-15
?
慕容森

TA貢獻(xiàn)1853條經(jīng)驗(yàn) 獲得超18個(gè)贊

登錄頁(yè)面和注銷頁(yè)面必須可供所有人訪問(wèn)。 在登錄配置和注銷配置之后,您錯(cuò)過(guò)了 .pemitAll() 方法。



查看完整回答
反對(duì) 回復(fù) 2022-06-15
  • 2 回答
  • 0 關(guān)注
  • 418 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)