j_security_check返回错误405(不支持请求方法'POST')

时间:2014-04-29 14:07:15

标签: java spring authentication spring-security

我有一个简单的登录页面。如果您提供正确的用户名和密码,它现在可以正常工作。问题是,如果不这样做,则不会将您重定向到authenticationFailureUrl,但会收到错误405.

唯一的日志行:

^2014-04-29 15:24:01,434       WARN org.springframework.web.servlet.PageNotFound    
[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)']    
Request method 'POST' not supported

有什么想法吗?

该应用程序在Weblogic 11g上运行

URL:

http://127.0.0.1:7013/app/j_security_check

弹簧security.xml文件

<sec:http create-session="stateless" auto-config="false" use-expressions="true" entry-point-ref="loginUrlAuthenticationEntryPoint">
        <sec:intercept-url pattern="/login*" access="permitAll()"/>
        <sec:intercept-url pattern="/logout" access="permitAll()"/>
        <sec:intercept-url pattern="/account" access="isAuthenticated()"/>
        <sec:intercept-url pattern="/**" access="hasRole('admin')" />

        [...]

        <sec:form-login login-page="/login" default-target-url="/" authentication-failure-url="/loginfailed"  />
    </sec:http>

的web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5" 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_2_5.xsd">

    <display-name>App</display-name>

    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <context-param>
        <param-name>locatorFactorySelector</param-name>
        <param-value>classpath*:beanRefContext.xml</param-value>
    </context-param>

    <context-param>
        <param-name>parentContextKey</param-name>
        <param-value>beanRefFactory</param-value>
    </context-param>

    <context-param>
        <param-name>contextInitializerClasses</param-name>
        <param-value>net.xxxxx.xxx.xxx.webapp.XxxxxxApplicationContextInitializer</param-value>
    </context-param>

    <servlet>
        <servlet-name>admin</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>admin</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>

    <mime-mapping>
        <extension>js</extension>
        <mime-type>application/javascript</mime-type>
    </mime-mapping>

    <mime-mapping>
        <extension>css</extension>
        <mime-type>text/css</mime-type>
    </mime-mapping>

    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>

    <session-config>
        <session-timeout>15</session-timeout>
    </session-config>

    <error-page>
        <error-code>403</error-code>
        <location>/error</location>
    </error-page>
    <error-page>
        <error-code>404</error-code>
        <location>/error</location>
    </error-page>
    <error-page>
        <exception-type>java.lang.Throwable</exception-type>
        <location>/error</location>
    </error-page>

    <login-config>
        <auth-method>FORM</auth-method>
        <form-login-config>
            <form-login-page>/login</form-login-page>
            <form-error-page>/loginfailed</form-error-page>
        </form-login-config>
    </login-config>

    <security-role>
        <description>Power Users</description>
        <role-name>admin</role-name>
    </security-role>

    <resource-ref id="ResourceRef_1">
        <res-ref-name>STPDataSource</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>
</web-app>

0 个答案:

没有答案