1
我已经使用正确运行的example project(documentation)创建了一个使用Eclipse在Tomcat 7上与Spring Security一起使用的简单JSF登录页面。上面的例子存储用户名,密码和角色的applicationContext-security.xml文件的格式如下:将Spring和JDBC集成到JSF2登录页面
<authentication-provider>
<password-encoder hash="md5" />
<user-service>
<user name="rod"
password="a564de63c2d0da68cf47586ee05984d7"
authorities="ROLE_SUPERVISOR, ROLE_USER, ROLE_TELLER" />
<user name="peter"
password="22b5c9accc6e1ba628cedc63a72d57f8"
authorities="ROLE_USER" />
</user-service>
</authentication-provider>
我想修改它,这样我可以通过JDBC使用认证数据库。在做了一个简单的修改之后,由于错误(Eclipse不提供细节,或者我不知道在哪里寻找),我无法再访问服务器上的我的项目(404)。你能给我一些关于可能出错的建议吗?谢谢。
下面是我的applicationContext更新-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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-2.0.1.xsd">
<global-method-security
secured-annotations="enabled">
</global-method-security>
<http
auto-config="true"
access-denied-page="/accessDenied.jsp">
<intercept-url
pattern="/faces/protected**"
access="ROLE_SUPERVISOR,ROLE_USER,ROLE_TELLER" />
<intercept-url
pattern="/**"
access="IS_AUTHENTICATED_ANONYMOUSLY" />
<form-login
login-processing-url="/j_spring_security_check"
login-page="/faces/login.jsf"
default-target-url="/"
authentication-failure-url="/faces/login.jsf" />
<logout
logout-url="/logout*"
logout-success-url="/" />
</http>
<authentication-provider>
<jdbc-user-service data-source-ref="dataSource"/>
</authentication-provider>
<beans:bean id="userDetailsService" class="org.springframework.security.userdetails.jdbc.JdbcDaoImpl">
<beans:property name="dataSource" ref="dataSource"/>
</beans:bean>
<beans:bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<beans:property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<beans:property name="url" value="jdbc:mysql:///mysampledb"/>
<beans:property name="username" value="root"/>
<beans:property name="password" value="root"/>
</beans:bean>
</beans:beans>
<豆:豆ID = “的UserDetailsService” 类= “org.springframework.security.userdetails.jdbc.JdbcDaoImpl”> <豆:属性名= “数据源” REF = “数据源”/> – Lyubomir
请结帐消息编辑器顶部的按钮和消息编辑器内右列的消息格式规则。 – BalusC