0

我有以下 spring 安全配置,如何更改它登录以基于 http GET 而不是 POST 工作,以便登录 url 类似于: *http://localhost/myapp/j_security_check?j_username=scott&j_password=tiger&landing=一些.html*

   <http auto-config="true" lowercase-comparisons="false">
    <intercept-url pattern="/images/**" filters="none"/>
    <intercept-url pattern="/styles/**" filters="none"/>
    <intercept-url pattern="/scripts/**" filters="none"/>
    <!--  Temp Below for testing reports -->
    <intercept-url pattern="/admin/**" access="ROLE_ADMIN"/>
    <intercept-url pattern="/passwordHint*" access="ROLE_ANONYMOUS,ROLE_ADMIN,ROLE_USER"/>
    <intercept-url pattern="/signup*" access="ROLE_ANONYMOUS,ROLE_ADMIN,ROLE_USER"/>
    <intercept-url pattern="/unauthorized*" access="ROLE_ANONYMOUS,ROLE_ADMIN,ROLE_USER"/>
    <intercept-url pattern="/**/*.action*" access="ROLE_ADMIN,ROLE_USER"/> 
    <logout success-handler-ref="logoutHandler" invalidate-session="true" logout-url="/logout"/>
    <form-login login-page="/login" authentication-success-handler-ref="authSuccessHandler" 
                authentication-failure-handler-ref="authFailureHandler" authentication-failure-url="/login?error=true"
                login-processing-url="/j_security_check"/>
    <remember-me user-service-ref="userDao" key="e37f4b31-0c45-11dd-bd0b-0800200c9a66"/>        
</http>
4

1 回答 1

0

我最终引入了带有 jquery 提交表单的附加静态 jsp 页面到 j_security_check

<script type="text/javascript">
$(function() {
    function getUrlParams() {
        var params = {};
        window.location.search.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(str, key, value) {
            params[key] = value;
        });

        return params;
    }
    $('#j_username').val(getUrlParams()['user']);
    $('#j_password').val(getUrlParams()['password']);
    $('#urlLoginForm').submit();
});
</script>

</head>

<form method="post" id="urlLoginForm" action="<c:url value='/j_security_check'/>">
<input type="hidden" id="j_username" name="j_username" /> 
<input type="hidden" id="j_password" name="j_password" />
</form>
于 2012-12-11T19:16:25.430 回答