-1

我正在尝试使用自定义服务类为身份验证提供者做一个弹簧安全 D/B 身份验证示例。

我收到 HTTP 404 状态 - 请求的资源 (/itrade-web/login) 不可用。我知道它是因为我能够解析到 jsp 页面。我确实在控制器中放了一些系统输出,但它没有被打印出来。所以控制直到控制器才会运行,并且在登录 url 被查找后它就出错了由于某些原因,安全上下文 xml。

PS - 我在控制台中没有收到任何错误。

[编辑]:我确定 Spring Security 劫持了传入的请求,然后在控制从安全 xml 返回到控制器之前出现问题,我无法弄清楚。

请帮助我了解这里到底是什么问题。我已包含以下所有代码:

应用程序上下文安全.xml

<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:security="http://www.springframework.org/schema/security"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
      http://www.springframework.org/schema/security
      http://www.springframework.org/schema/security/spring-security-3.1.xsd
      http://www.springframework.org/schema/tx 
      http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">

<security:http auto-config="true" use-expressions="true">
    <security:intercept-url pattern="/welcome.html"
        access="hasRole('ROLE_USER')" />
    <security:form-login login-page="/login"
        default-target-url="/welcome" authentication-failure-url="/loginfailed" />
    <security:logout logout-success-url="/logout" />
</security:http>

<security:authentication-manager>
    <security:authentication-provider
        user-service-ref="LoginUserDetailsService">
    </security:authentication-provider>
</security:authentication-manager>

<bean id="LoginUserDetailsService"
    class="com.inf.trade.core.service.security.LoginUserDetailsServiceImpl">
    <property name="loginDAO" ref="loginDAOImpl" />
</bean>

<bean id="loginDAOImpl" class="com.inf.trade.core.dao.security.LoginDAOImpl">
    <property name="sessionFactory"> <ref bean ="sessionFactory"/> </property>
</bean>

spring-servlet.xml

<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<context:component-scan base-package="com.inf.trade.client.controller" />
<context:annotation-config />

<bean id="tilesViewResolver"
    class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    <property name="viewClass">
        <value>
            org.springframework.web.servlet.view.tiles2.TilesView
        </value>
    </property>
    <property name="order" value="0" />
</bean>

<bean id="jspViewResolver"
      class="org.springframework.web.servlet.view.InternalResourceViewResolver" >
          <property name="prefix">
             <value>/pages/</value>
          </property>
          <property name="suffix">
             <value>.jsp</value>
          </property>
      <property name="order" value="1" />
</bean>

<bean id="tilesConfigurer"
    class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
    <property name="definitions">
        <list>
            <value>/WEB-INF/tiles.xml</value>
        </list>
    </property>
</bean>
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
    <property name="messageConverters">
        <list>
            <bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
                <property name="objectMapper" ref="jacksonObjectMapper" />
            </bean>
        </list>
    </property>
</bean>

<bean id="jacksonObjectMapper" class="org.codehaus.jackson.map.ObjectMapper" />

<!-- Application Message Bundle -->
<bean id="messageSource"
    class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    <property name="basename" value="classpath:messages" />
    <property name="defaultEncoding" value="UTF-8" />
    <property name="fileEncodings" value="UTF-8" />
    <property name="fallbackToSystemLocale" value="false" />
</bean>

index.jsp(它在 webapp 中)

<%@ page session="false" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <link rel="stylesheet" href="<c:url value='/static/css/tutorial.css'/>"       type="text/css" />
  <title>Home Page</title>
  </head>
  <body>
  <div id="content">
  <h1>Home Page</h1>
  <p>
  Anyone can view this page.
  </p>
  <p><a href="welcome.html">Login page</a></p>
  </div>
  </body>
  </html>

login.jsp(它在 webapp/pages 内,welcome.jsp 也在 webapp/pages 内)

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
<title>Login Page</title>
<style>
.errorblock {
color: #ff0000;
background-color: #ffEEEE;
border: 3px solid #ff0000;
padding: 8px;
margin: 16px;
 }
 </style>
 </head>
 <body onload='document.f.j_username.focus();'>
<h3>Login with Username and Password (Authentication with Database)</h3>

<c:if test="${not empty error}">
    <div class="errorblock">
        Your login attempt was not successful, try again.<br /> Caused :
        ${sessionScope["SPRING_SECURITY_LAST_EXCEPTION"].message}
    </div>
</c:if>

<form name='f' action="<c:url value='j_spring_security_check' />"
    method='POST'>

    <table>
        <tr>
            <td>User:</td>
            <td><input type='text' name='j_username' value=''>
            </td>
        </tr>
        <tr>
            <td>Password:</td>
            <td><input type='password' name='j_password' />
            </td>
        </tr>
        <tr>
            <td colspan='2'><input name="submit" type="submit"
                value="submit" />
            </td>
        </tr>
        <tr>
            <td colspan='2'><input name="reset" type="reset" />
            </td>
        </tr>
    </table>

</form>

BaseController.java

@Controller
@SessionAttributes({ "footer", "headerObject", "menuObject" })
public class BaseController {

@Autowired
private FooterDelegate footerDelegate;

@Autowired
private HeaderDelegate headerDelegate;

@Autowired
//private IMenuDelegate menuDelegate;

/*public IMenuDelegate getMenuDelegate() {
    return menuDelegate;
}

public void setMenuDelegate(MenuDelegateDirect menuDelegate) {
    this.menuDelegate = menuDelegate;
}*/

public FooterDelegate getFooterDelegate() {
    return footerDelegate;
}

public void setFooterDelegate(FooterDelegate footerDelegate) {
    this.footerDelegate = footerDelegate;
}

public HeaderDelegate getHeaderDelegate() {
    return headerDelegate;
}

public void setHeaderDelegate(HeaderDelegate headerDelegate) {
    this.headerDelegate = headerDelegate;
}

@RequestMapping("/welcome")
public ModelAndView welcome(Model model) {


    System.out.println("Inside Welcome1");

    String userId = "hammid_hani";
    FooterModel footerVO = new FooterModel();
    footerVO.setFooterListTop(footerDelegate.readFooter(userId)
            .getFooterListTop());
    footerVO.setFooterListBottom(footerDelegate.readFooter(userId)
            .getFooterListBottom());
    model.addAttribute("footer", footerVO);




    HeaderModel headerVO = new HeaderModel();
    headerVO.setTopLeft(headerDelegate.fetchHeader(userId).getTopLeft());
    headerVO.setTopRight(headerDelegate.fetchHeader(userId).getTopRight());
    headerVO.setTickerList(headerDelegate.fetchHeader(userId)
            .getTickerList());
    model.addAttribute("headerObject", headerVO);




    MenuModel menuVO = new MenuModel();
    try {
        //menuVO.setMenuList(menuDelegate.fetchMenu(userId).getMenuList());

        model.addAttribute("menuObject", menuVO);

    } catch (Exception e) {

    }
    System.out.println("Inside Welcome");

    /*User user = (User)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    String name = user.getUsername();

    ModelMap mmap = new ModelMap();
    mmap.addAttribute("username", name);
    mmap.addAttribute("message", "Spring Security login + database example");*/
    return new ModelAndView("welcome");
}

//@RequestMapping(value="/login", method = RequestMethod.GET)
@RequestMapping("/login")
public ModelAndView login(Model model) {
    System.out.println("Inside /login...");
    return new ModelAndView("login");
}
/*public String login(ModelMap model) {

    System.out.println("Inside /login...");
    return "login";

}*/

@RequestMapping(value="/loginfailed", method = RequestMethod.GET)
public String loginerror(ModelMap model) {

    model.addAttribute("error", "true");
    return "login";

}

@RequestMapping(value="/logout", method = RequestMethod.GET)
public String logout(ModelMap model) {

    return "login";
}}

[更新] 下面是 Tiles.xml

   <?xml version="1.0" encoding="UTF-8" ?>
   <!DOCTYPE tiles-definitions PUBLIC
   "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
   "http://tiles.apache.org/dtds/tiles-config_2_0.dtd">

  <tiles-definitions>
<definition name="base.definition" template="/pages/portalLayout.jsp">
    <put-attribute name="header" value="/pages/portalHeader.jsp" /> 
    <put-attribute name="menu" value="/pages/portalMenu.jsp" /> 
    <put-attribute name="body" value="" />
    <put-attribute name="footer" value="/pages/portalFooter.jsp" />
</definition>

<definition name="BasketOrders" extends="base.definition">
    <put-attribute name="body" value="/pages/BasketOrders.jsp" />
</definition>

<definition name="portfolio" extends="base.definition">
    <put-attribute name="body" value="/pages/portfolio.jsp" />
</definition>

<definition name="orderSummary" extends="base.definition">
    <put-attribute name="body" value="/pages/orderSummary.jsp" />
</definition>

<definition name="accountSummary" extends="base.definition">
    <put-attribute name="body" value="/pages/accountSummary.jsp" />
</definition>

下面是我在 pom.XML 中的 SL4J 配置

    <properties>
    <java-version>1.6</java-version>
    <org.springframework-version>3.2.0.RELEASE</org.springframework-version>
    <org.springsec-version>3.1.3.RELEASE</org.springsec-version>
    <org.aspectj-version>1.7.1</org.aspectj-version>
    <org.slf4j-version>1.5.10</org.slf4j-version>
    <org.apache.cxf-version>2.6.5</org.apache.cxf-version>
    <hibernate.version>4.1.0.Final</hibernate.version>     
    <tiles.version>2.2.2</tiles.version>
    </properties>
    <!-- Logging --> 
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${org.slf4j-version}</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jcl-over-slf4j</artifactId>
        <version>${org.slf4j-version}</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>${org.slf4j-version}</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.15</version>
        <exclusions>
            <exclusion>
                <groupId>javax.mail</groupId>
                <artifactId>mail</artifactId>
            </exclusion>
            <exclusion>
                <groupId>javax.jms</groupId>
                <artifactId>jms</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.sun.jdmk</groupId>
                <artifactId>jmxtools</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.sun.jmx</groupId>
                <artifactId>jmxri</artifactId>
            </exclusion>
        </exclusions>
        <scope>runtime</scope>
    </dependency>

[更新] 下面是我的 web.xml

 <?xml version="1.0" encoding="UTF-8"?>
 <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
 <display-name>SpringPOC</display-name>
 <servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
        /WEB-INF/applicationContextDirect.xml
        /WEB-INF/applicationContext-security.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>
</web-app>

[更新]服务器启动时登录:

            SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
    SLF4J: Defaulting to no-operation (NOP) logger implementation
    SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
    [INFO] Scanning for projects...
    Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-assembly-plugin/2.2-beta-5/maven-assembly-plugin-2.2-beta-5.pom
    [WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5: Plugin org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-assembly-plugin:jar:2.2-beta-5
    Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-antrun-plugin/1.3/maven-antrun-plugin-1.3.pom
    [WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-antrun-plugin:1.3: Plugin org.apache.maven.plugins:maven-antrun-plugin:1.3 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-antrun-plugin:jar:1.3
    [WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5: Plugin org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-assembly-plugin:jar:2.2-beta-5
    Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/2.1/maven-dependency-plugin-2.1.pom
    [WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-dependency-plugin:2.1: Plugin org.apache.maven.plugins:maven-dependency-plugin:2.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-dependency-plugin:jar:2.1
    Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-release-plugin/2.0/maven-release-plugin-2.0.pom
    [WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-release-plugin:2.0: Plugin org.apache.maven.plugins:maven-release-plugin:2.0 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-release-plugin:jar:2.0
    [INFO]                                                                         
    [INFO] ------------------------------------------------------------------------
    [INFO] Building trade-web 0.0.1
    [INFO] ------------------------------------------------------------------------
    [WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5: Plugin org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-assembly-plugin:jar:2.2-beta-5
    [WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-antrun-plugin:1.3: Plugin org.apache.maven.plugins:maven-antrun-plugin:1.3 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-antrun-plugin:jar:1.3
    [WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5: Plugin org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-assembly-plugin:jar:2.2-beta-5
    [WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-dependency-plugin:2.1: Plugin org.apache.maven.plugins:maven-dependency-plugin:2.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-dependency-plugin:jar:2.1
    [WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-release-plugin:2.0: Plugin org.apache.maven.plugins:maven-release-plugin:2.0 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-release-plugin:jar:2.0
    [INFO] 
    [INFO] >>> tomcat-maven-plugin:1.1:run (default-cli) @ trade-web >>>
    [INFO] 
    [INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ trade-web ---
    [debug] execute contextualize
    [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
    [INFO] Copying 1 resource
    [INFO] 
    [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ trade-web ---
    [INFO] Nothing to compile - all classes are up to date
    [INFO] 
    [INFO] <<< tomcat-maven-plugin:1.1:run (default-cli) @ trade-web <<<
    [INFO] 
    [INFO] --- tomcat-maven-plugin:1.1:run (default-cli) @ trade-web ---
    [INFO] Running war on http://localhost:8080/trade-web
    [INFO] Using existing Tomcat server configuration at D:\MyWorkspaces\SecurityWS\trade-web\target\tomcat
    Mar 25, 2013 5:33:36 PM org.apache.catalina.startup.Embedded start
    INFO: Starting tomcat server
    Mar 25, 2013 5:33:36 PM org.apache.catalina.core.StandardEngine start
    INFO: Starting Servlet Engine: Apache Tomcat/6.0.29
    SLF4J: Class path contains multiple SLF4J bindings.
    SLF4J: Found binding in [jar:file:/D:/MyWorkspaces/SecurityWS/trade-web/src/main/webapp/WEB-INF/lib/slf4j-log4j12-1.5.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    SLF4J: Found binding in [jar:file:/C:/Users/karthik_chellappan/.m2/repository/org/slf4j/slf4j-log4j12/1.5.10/slf4j-log4j12-1.5.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
    Mar 25, 2013 5:33:37 PM org.apache.catalina.core.ApplicationContext log
    INFO: Initializing Spring root WebApplicationContext
    INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
    INFO : org.springframework.web.context.support.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Mon Mar 25 17:33:37 IST 2013]; root of context hierarchy
    INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContextDirect.xml]
    INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext-security.xml]
    INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@17820c3: defining beans [accountSummaryDelegate,accountSummaryServiceDelegate,accountSummaryServiceImpl,accountSummaryDAOImpl,basketOrdersDelegate,basketOrdersServiceDelegate,basketOrdersServiceImpl,basketOrdersDAOImpl,portfolioDelegate,portfolioServiceDelegate,portfolioServiceImpl,portfolioDAOImpl,orderPadDelegate,orderPadServiceDelegate,orderPadServiceImpl,orderPadDAOImpl,headerDelegate,headerServiceDelegate,headerServiceImpl,headerDAOImpl,footerDelegate,footerServiceDelegate,footerServiceImpl,footerDAOImpl,sessionFactory,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,transactionManager,dataSource,org.springframework.security.filterChains,org.springframework.security.filterChainProxy,org.springframework.security.web.PortMapperImpl#0,org.springframework.security.web.PortResolverImpl#0,org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0,org.springframework.security.authentication.ProviderManager#0,org.springframework.security.web.context.HttpSessionSecurityContextRepository#0,org.springframework.security.web.authentication.session.SessionFixationProtectionStrategy#0,org.springframework.security.web.savedrequest.HttpSessionRequestCache#0,org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler#0,org.springframework.security.access.vote.AffirmativeBased#0,org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0,org.springframework.security.web.access.DefaultWebInvocationPrivilegeEvaluator#0,org.springframework.security.authentication.AnonymousAuthenticationProvider#0,org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint#0,org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0,org.springframework.security.userDetailsServiceFactory,org.springframework.security.web.DefaultSecurityFilterChain#0,org.springframework.security.authentication.dao.DaoAuthenticationProvider#0,org.springframework.security.authentication.DefaultAuthenticationEventPublisher#0,org.springframework.security.authenticationManager,LoginUserDetailsService,loginDAOImpl]; root of factory hierarchy
    WARN : org.hibernate.mapping.RootClass - HHH000038: Composite-id class does not override equals(): com.inf.trade.core.entity.MarginRequirementsDO
    WARN : org.hibernate.mapping.RootClass - HHH000039: Composite-id class does not override hashCode(): com.inf.trade.core.entity.MarginRequirementsDO
    ERROR: org.hibernate.tool.hbm2ddl.SchemaUpdate - HHH000388: Unsuccessful: alter table PRDtradeDB.USER_AUTHENTICATION add access number(10,0)
    ERROR: org.hibernate.tool.hbm2ddl.SchemaUpdate - ORA-00904: : invalid identifier

    INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 6196 ms
    Mar 25, 2013 5:33:43 PM org.apache.catalina.core.ApplicationContext log
    INFO: Initializing Spring FrameworkServlet 'spring'
    INFO : org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'spring': initialization started
    INFO : org.springframework.web.context.support.XmlWebApplicationContext - Refreshing WebApplicationContext for namespace 'spring-servlet': startup date [Mon Mar 25 17:33:43 IST 2013]; parent: Root WebApplicationContext
    INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring-servlet.xml]
    INFO : org.springframework.context.annotation.ClassPathBeanDefinitionScanner - JSR-330 'javax.inject.Named' annotation found and supported for component scanning
    INFO : org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
    INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1feb2ea: defining beans [accountSummaryController,baseController,basketOrdersController,ordersController,portfolioController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,tilesViewResolver,tilesConfigurer,org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#0,jacksonObjectMapper,messageSource,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@17820c3
    WARN : org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor - Autowired annotation should be used on methods with actual parameters: public com.inf.trade.client.delegate.footer.FooterDelegate com.inf.trade.client.controller.base.BaseController.getFooterDelegate()
    INFO : org.springframework.web.servlet.view.tiles2.TilesConfigurer - TilesConfigurer: adding definitions [/WEB-INF/tiles.xml]

    INFO : org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Mapped URL path [/logout] onto handler 'baseController'
    INFO : org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Mapped URL path [/logout.*] onto handler 'baseController'
    INFO : org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Mapped URL path [/logout/] onto handler 'baseController'
    INFO : org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Mapped URL path [/welcome] onto handler 'baseController'
    INFO : org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Mapped URL path [/welcome.*] onto handler 'baseController'
    INFO : org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Mapped URL path [/welcome/] onto handler 'baseController'
    INFO : org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Mapped URL path [/login] onto handler 'baseController'
    INFO : org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Mapped URL path [/login.*] onto handler 'baseController'
    INFO : org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Mapped URL path [/login/] onto handler 'baseController'
    INFO : org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Mapped URL path [/loginfailed] onto handler 'baseController'
    INFO : org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Mapped URL path [/loginfailed.*] onto handler 'baseController'
    INFO : org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Mapped URL path [/loginfailed/] onto handler 'baseController'
    INFO : org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Mapped URL path [/getQuote] onto handler 'baseController'
    INFO : org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Mapped URL path [/getQuote.*] onto handler 'baseController'
    INFO : org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Mapped URL path [/getQuote/] onto handler 'baseController'

    INFO : org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'spring': initialization completed in 693 ms
    Mar 25, 2013 5:33:44 PM org.apache.coyote.http11.Http11Protocol init
    INFO: Initializing Coyote HTTP/1.1 on http-8080
    Mar 25, 2013 5:33:44 PM org.apache.coyote.http11.Http11Protocol start
    INFO: Starting Coyote HTTP/1.1 on http-8080

[更新] 我有 log4j 用于日志记录,SL4J 是使用 log4j 进行日志记录的接口。现在我得到了错误,理想情况下我根本不应该看到日志,而是看到信息和警告。

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

我想知道我是怎么看到这个的,这意味着尽管出现了 SL4J 错误,但 log4j 已启用。

4

1 回答 1

0

我让它工作了。这是因为登录页面缺少“.html”。

<security:http auto-config="true" use-expressions="true">
    <security:intercept-url pattern="/welcome.html"
        access="hasRole('ROLE_USER')" />
    <security:form-login login-page="/login.html"
        default-target-url="/welcome.html" authentication-failure-url="/loginfailed.html" />
    <security:logout logout-success-url="/logout.html" />
</security:http>

它期待 *.html 因为我在 web.xml 中给出了相同的

<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>

@krisl - 感谢您的宝贵时间。

于 2013-03-26T09:10:30.940 回答