2014-03-30 29 views
-1

這是我的web.xml文件DelegatingFilterProxy的過濾器沒有發現和調用

<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      

不知道一個片段 - 爲什麼沒有得到調用它。

+1

您能否提供您正在使用的整個web.xml以及您正在使用的Spring配置文件? – geoand

+0

你可以請分享你的電子郵件ID,我想這將是很難分享堆棧溢出。謝謝。 –

+0

它可能會更好地把它放在pastebin爲了讓其他用戶也能夠查看它 – geoand

回答

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' /> 
0

一個問題可能是您需要在xml文件位置之間添加逗號。 結賬this回答詳情

+0

也沒有這樣工作。我跟着[鏈接] http://www.baeldung.com/no-bean-named-springsecurityfilterchain-is-defined –

相關問題