这是我的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>
ERROR - SEVERE: Exception starting filter springSecurityFilterChain
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSecurityFilterChain' is defined
没有想法 - 为什么不被调用。
答案 0 :(得分:0)
WEB.XML -
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Processes application requests -->
<servlet>
<servlet-name>login</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring/appServlet/login-security.xml
/WEB-INF/spring/appServlet/login-servlet.xml
/WEB-INF/spring/appServlet/login-service.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>login</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<filter>
<filter-name>springSecurityFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
LOGIN-SECURITY.xml
<beans:import resource="login-service.xml"/>
<security:http auto-config="true">
<security:intercept-url pattern='/home*'
access='ROLE_USER,ROLE_ADMIN' />
<security:intercept-url pattern='/admin*'
access='ROLE_ADMIN' />
<security:form-login login-page='/login.jsp'
default-target-url='/home' authentication-failure-url='/login.jsp?error=true' />
<security:logout logout-success-url='/login.jsp' />
<security:anonymous username='guest'
granted-authority='ROLE_GUEST' />
<security:remember-me />
</security:http>
<security:authentication-manager>
<security:authentication-provider>
<security:jdbc-user-service
data-source-ref='myDataSource'
users-by-username-query="select username, password, 'true' as enabled from USER_DETAILS where username=?"
authorities-by-username-query="select USER_DETAILS.username , USER_AUTH.AUTHORITY as authorities from USER_DETAILS,USER_AUTH
where USER_DETAILS.username = ? AND USER_DETAILS.username=USER_AUTH.USERNAME"></security:jdbc-user-service>
</security:authentication-provider>
</security:authentication-manager>
LOGIN-SERVICE.xml
<beans:property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<beans:property name="url" value="jdbc:oracle:thin:@localhost:1521:XE" />
<beans:property name="username" value="system" />
<beans:property name="password" value="oracle" />
LOGIN-SERVLET.xml
<context:component-scan base-package="com.poc.security" />
<bean id="internalResourceResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
<bean
class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<bean
class='org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter' />
答案 1 :(得分:0)
一个问题可能是您需要在xml文件位置之间添加逗号。 查看this答案了解更多详情