我自定义了一个AuthenticationProcessingFilter,但配置后发现网站没反应,根本出现不了登陆页面,TOMCAT下也没见错误自各位高人帮我看看吧
web.xml
[code]
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 
xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param><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>
<welcome-file-list>
  <welcome-file>index.jsp</welcome-file>
</welcome-file-list><listener>
     <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
 </listener>
 
 
  
</web-app>[/code]application.xml
[code]
<?xml version="1.0" encoding="UTF-8"?>
<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.5.xsd
    http://www.springframework.org/schema/security
    http://www.springframework.org/schema/security/spring-security-2.0.4.xsd">    <http auto-config="false" entry-point-ref="authenticationProcessingFilterEntryPoint">
        <intercept-url pattern="/admin.jsp" access="ROLE_ADMIN" />
        <intercept-url pattern="/**" access="ROLE_USER" />
    </http>    <authentication-provider>
         <password-encoder hash="md5"/>
         <jdbc-user-service data-source-ref="dataSource"
            users-by-username-query="select userid,password,workstatus as enabled from wbxUser where userid=?"
            authorities-by-username-query="select a.userid,b.groupname as authority from wbxuser a,usergroup b where a.groupid=b.groupid and userid=?"/>
    </authentication-provider>
    
    <beans:bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <beans:property name="driverClassName" value="com.microsoft.jdbc.sqlserver.SQLServerDriver"/>
        <beans:property name="url" value="jdbc:microsoft:sqlserver://10.224.104.38:1433;databasename=forumlocal"/>
        <beans:property name="username" value="sa"/>
        <beans:property name="password" value="pass"/>
    </beans:bean>
    //<font color=red>这是我自定义的一个bean</font>
    <beans:bean id="authenticationProcessingFilter" class="mycompany.login.MyAuthenticationProcessingFilter">
        <custom-filter position="AUTHENTICATION_PROCESSING_FILTER"/>
        <beans:property name="defaultTargetUrl" value="/index.jsp"/>
        <beans:property name="authenticationManager" ref="authenticationManager"/> //<font color=red>不太懂这,但还是配了</font>
    </beans:bean>
    
     <beans:bean id="authenticationProcessingFilterEntryPoint" class="org.springframework.security.ui.webapp.AuthenticationProcessingFilterEntryPoint">
        <beans:property name="loginFormUrl" value="/login.jsp"/>
        <beans:property name="forceHttps" value="false"/>
    </beans:bean>
    
    <authentication-manager alias="authenticationManager"/>
    
</beans:beans>
[/code]

解决方案 »

  1.   


    <?xml version="1.0" encoding="UTF-8"?>
    <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.5.xsd
        http://www.springframework.org/schema/security
        http://www.springframework.org/schema/security/spring-security-2.0.4.xsd">    <http auto-config="false" entry-point-ref="authenticationProcessingFilterEntryPoint">
            <intercept-url pattern="/admin.jsp" access="ROLE_ADMIN" />
            <intercept-url pattern="/**" access="ROLE_USER" />
        </http>    <authentication-provider>
             <password-encoder hash="md5"/>
             <jdbc-user-service data-source-ref="dataSource"
                users-by-username-query="select userid,password,workstatus as enabled from wbxUser where userid=?"
                authorities-by-username-query="select a.userid,b.groupname as authority from wbxuser a,usergroup b where a.groupid=b.groupid and userid=?"/>
        </authentication-provider>
        
        <beans:bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            <beans:property name="driverClassName" value="com.microsoft.jdbc.sqlserver.SQLServerDriver"/>
            <beans:property name="url" value="jdbc:microsoft:sqlserver://10.224.104.38:1433;databasename=forumlocal"/>
            <beans:property name="username" value="sa"/>
            <beans:property name="password" value="pass"/>
        </beans:bean>
        
        <beans:bean id="authenticationProcessingFilter" class="mycompany.login.MyAuthenticationProcessingFilter">
            <custom-filter position="AUTHENTICATION_PROCESSING_FILTER"/>
            <beans:property name="defaultTargetUrl" value="/index.jsp"/>
            <beans:property name="authenticationManager" ref="authenticationManager"/>
        </beans:bean>
        
         <beans:bean id="authenticationProcessingFilterEntryPoint" class="org.springframework.security.ui.webapp.AuthenticationProcessingFilterEntryPoint">
            <beans:property name="loginFormUrl" value="/login.jsp"/>
            <beans:property name="forceHttps" value="false"/>
        </beans:bean>
        
        <authentication-manager alias="authenticationManager"/>
        
    </beans:beans>[/code]web.xml<?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

    <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param><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>
    <welcome-file-list>
      <welcome-file>index.jsp</welcome-file>
    </welcome-file-list><listener>
         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
     </listener>
     
     
      
    </web-app>[code=Java]