2017-04-18 84 views
-1

我和春天有個安全的版本2.0.4運行的應用程序,現在我需要更改到4.2.0版本...彈簧安全遷移到4.2.0

我創建登錄這個示例頁面:

http://facestutorials.icefaces.org/tutorial/spring-security-basic.html

springSecurityLogin.jspx

<?xml version="1.0" encoding="ISO-8859-1" ?> 
<f:view xmlns:f="http://java.sun.com/jsf/core" 
     xmlns:h="http://java.sun.com/jsf/html" 
     xmlns:ice="http://www.icesoft.com/icefaces/component"> 
    <ice:outputDeclaration doctypeRoot="HTML" 
          doctypePublic="-//W3C//DTD HTML 4.01 Transitional//EN" 
          doctypeSystem="http://www.w3.org/TR/html4/loose.dtd"/> 
    <html> 
    <head> 
     <title>Spring Security Login</title> 
    </head> 
    <body> 
    <ice:form partialSubmit="false"> 
     <ice:panelGrid columns="2"> 
      <ice:outputLabel value="User Name" for="j_username"/> 
      <ice:inputText id="j_username" 
          value="#{loginBean.userId}" size="40" 
          maxlength="80"/> 
      <ice:outputLabel value="Password" for="j_password"/> 
      <ice:inputSecret id="j_password" 
          value="#{loginBean.password}" size="40" 
          maxlength="80"/> 
     </ice:panelGrid> 
     <ice:commandButton actionListener="#{loginBean.login}" value="Login"/> 
     <ice:messages style="color: red;"/> 
    </ice:form> 
    </body> 
    </html> 
</f:view> 

登錄方法:

public void login(ActionEvent e) throws java.io.IOException { 
    FacesContext.getCurrentInstance().getExternalContext().redirect("/spring-authentication/j_spring_security_check?j_username=" + userId + "&j_password=" + password); 
} 

這是工作......但是,當我的春天安全的版本改爲4.2.0我得到了HTTP錯誤404時嘗試登錄。

有人知道發生了什麼?

+1

有移民指南。 –

+0

遷移指南不適用於冰點... – BrunoTS

+1

這是什麼意思? –

回答

0

的問題如下...

彈簧安全允許驗證HTTP調用與GET或POST,遷移完成後,默認情況下它是隻允許POST調用。

爲了解決這個問題,只需要插入您AuthenticationFilter以下行:

UsernamePasswordAuthenticationFilter.setPostOnly(false); 

這解決問題。