0
我對Spring/Spring Security頗爲陌生,我已經盡力解決了這個問題,但我似乎並沒有一遍又一遍地得到它。問題如下:登錄無法正常工作 - 即使使用正確的憑證,它仍會告訴他們看起來不正確。 我使用Spring Security和Spring mvc + Oracle(hibernate + jpa)。我會很感激任何幫助,非常感謝你提前!Spring Security登錄問題 -
這是我的配置文件。 (部分)
1. security.xml
<http auto-config="true">
<intercept-url pattern="/welcome*" access="ROLE_USER" />
<form-login login-page="/login" default-target-url="/welcome"
authentication-failure-url="/loginfailed" />
<logout logout-success-url="/logout" />
</http>
<!-- <password-encoder hash="md5" /> -->
<authentication-manager>
<authentication-provider>
<jdbc-user-service data-source-ref="dataSource"
users-by-username-query="
SELECT username, password, 'TRUE'
FROM users WHERE username=?"
authorities-by-username-query="
SELECT u.username, ur.authority FROM users u, user_roles ur
WHERE u.user_id = ur.user_id AND u.username=? " />
</authentication-provider>
</authentication-manager>
2. web.xml
<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>
3. data.xml
<!-- Transaction managing using the @Transactional annotation -->
<tx:annotation-driven transaction-manager="transactionManager" />
<!-- Transaction Manager -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/pages/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames">
<list>
<value>msgs</value>
</list>
</property>
<property name="defaultEncoding" value="UTF-8" />
</bean>
<!-- ////////////////////////////////////////////////////////////////////////// -->
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
p:location="/WEB-INF/jdbc.properties"/>
<!-- ////////////////////////////////////////////////////////////////////////// "-->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass" value="${jdbc.driverClassName}" />
<property name="jdbcUrl" value="${jdbc.databaseurl}" />
<property name="user" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
<!-- ////////////////////////////////////////////////////////////////////////// -->
<!-- Hibernate SessionFactory configuration -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="com.tsystems.javaschool.kts.domain" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.dialect">${jdbc.dialect}</prop>
<prop key="hibernate.connection.charSet">UTF-8</prop>
</props>
</property>
</bean>
你還可以發佈你的登錄jsp頁面嗎? 你在日誌中看到選擇用戶查詢嗎? –
當然,這裏http://pastebin.com/mhAx7XcE – user1834170
你做了什麼試圖解決這個問題?如果你列出,你可以拯救我們不建議你已經嘗試過的東西。 – Codeguy007