2015-08-11 3 views
0

Отправка моей формы входа в систему не работает. Я получаю сообщение «Запрошенный ресурс недоступен» при отправке формы входа, которая обращается к/j_spring_security_check со стандартным фильтром.j_spring_security_check - Запрошенный ресурс недоступен

Мое приложение-servlet.xml:

<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" 
xmlns:security="http://www.springframework.org/schema/security" 
xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd 
http://www.springframework.org/schema/security 
http://www.springframework.org/schema/security/spring-security-4.0.xsd"> 

<!-- enable use-expressions --> 
<http auto-config="true" use-expressions="true"> 

    <intercept-url pattern="/inside**" access="hasRole('ROLE_USER')" /> 

    <!-- access denied page --> 
    <access-denied-handler error-page="/403" /> 

    <form-login 
     login-page="/login" 
     default-target-url="/welcome" 
     authentication-failure-url="/login?error" 
     username-parameter="username" 
     password-parameter="password" /> 

    <logout logout-success-url="/login?logout" /> 

    <!-- enable csrf protection --> 
    <csrf/> 
</http> 

<!-- Select users and user_roles from database --> 
<authentication-manager> 
    <authentication-provider> 
    <jdbc-user-service data-source-ref="dataSource" 
     users-by-username-query= 
     "select email,password from users where username=?" /> 
    </authentication-provider> 
</authentication-manager> 

<http auto-config="false" entry-point-ref="authenticationProcessingFilterEntryPoint"> 

    <intercept-url pattern="/resettingPassword.do**" access="ROLE_ADMIN" /> 
    <intercept-url pattern="/resetPassword.do**" access="ROLE_ADMIN" /> 
    <logout logout-success-url="/index.jsp" invalidate-session="true" /> 
</http> 

весна-database.xml выглядит следующим образом:

<beans xmlns="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.0.xsd"> 

<bean id="daoImpl" class="com.afterguard.sailplanner.dao.DaoImpl"> 
    <property name="dataSource" ref="dataSource" /> 
</bean> 

<bean id="dataSource" 
    class="org.springframework.jdbc.datasource.DriverManagerDataSource"> 

    <property name="driverClassName" value="com.mysql.jdbc.Driver" /> 
    <property name="url" value="jdbc:mysql://localhost:3306/sailplanner" /> 
    <property name="username" value="sailplanner" /> 
    <property name="password" value="sailplanner2" /> 
</bean> 

И моя весна-security.xml например:

<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" 
xmlns:security="http://www.springframework.org/schema/security" 
xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd 
http://www.springframework.org/schema/security 
http://www.springframework.org/schema/security/spring-security-4.0.xsd"> 

<!-- enable use-expressions --> 
<http auto-config="true" use-expressions="true"> 

    <intercept-url pattern="/inside**" access="hasRole('ROLE_USER')" /> 

    <!-- access denied page --> 
    <access-denied-handler error-page="/403" /> 

    <form-login 
     login-page="/login" 
     default-target-url="/welcome" 
     authentication-failure-url="/login?error" 
     username-parameter="username" 
     password-parameter="password" /> 

    <logout logout-success-url="/login?logout" /> 

    <!-- enable csrf protection --> 
    <csrf/> 
</http> 

<!-- Select users and user_roles from database --> 
<authentication-manager> 
    <authentication-provider> 
    <jdbc-user-service data-source-ref="dataSource" 
     users-by-username-query= 
     "select email,password from users where username=?" /> 
    </authentication-provider> 
</authentication-manager> 

<http auto-config="false" entry-point-ref="authenticationProcessingFilterEntryPoint"> 

    <intercept-url pattern="/resettingPassword.do**" access="ROLE_ADMIN" /> 
    <intercept-url pattern="/resetPassword.do**" access="ROLE_ADMIN" /> 
    <logout logout-success-url="/index.jsp" invalidate-session="true" /> 
</http> 

У меня есть следующий web.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xmlns="http://java.sun.com/xml/ns/javaee" 
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 
      version="3.0"> 
    <display-name>SailPlanner</display-name> 
    <welcome-file-list> 
    <welcome-file>index.jsp</welcome-file> 
    </welcome-file-list> 

    <servlet> 
    <servlet-name>sailplanner</servlet-name> 
    <servlet-class> 
      org.springframework.web.servlet.DispatcherServlet 
     </servlet-class> 
    <load-on-startup>1</load-on-startup> 
    </servlet> 
    <servlet-mapping> 
    <servlet-name>sailplanner</servlet-name> 
    <url-pattern>/welcome</url-pattern> 
    <url-pattern>/users</url-pattern> 
    <url-pattern>/create_event</url-pattern> 
    <url-pattern>/save_event</url-pattern> 
    <url-pattern>/login</url-pattern> 
    <url-pattern>/logout</url-pattern> 
    <url-pattern>/403</url-pattern> 
    </servlet-mapping> 

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

    <context-param> 
    <param-name>contextConfigLocation</param-name> 
    <param-value> 
      /WEB-INF/sailplanner-servlet.xml, 
      /WEB-INF/spring-security.xml, 
      /WEB-INF/spring-database.xml 
     </param-value> 
    </context-param> 

     <!-- Spring Security --> 
    <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> 

</web-app> 

Моя установка выглядит следующим образом: enter image description here

+0

Сообщите нам об этом здесь. Я свежий весной, но могу сказать, что у моего рабочего приложения нет повторяющихся конфигураций форм. – ChiefTwoPencils

ответ

3

Похоже, вам не хватает ...

login-processing-url="/j_spring_security_check" 

в вашем <form-login

См. Spring 3 -> 4 Migration Guide for XML. Двойной код xml также выглядит подозрительным.

Смежные вопросы