有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

在DispatcherServlet中找不到URI为[***]的HTTP请求的java映射

这是我的密码。我不知道这是怎么回事

<web-app id="WebApp_ID" version="2.4"
        xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee

http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

    <display-name>Spring Security Application</display-name>

    <!-- Spring MVC -->
    <servlet>
        <servlet-name>mvc-dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>mvc-dispatcher</servlet-name>
        <url-pattern>/</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/spring-security.xml,
            /WEB-INF/spring-database.xml
        </param-value>
    </context-param>

    <!-- Spring Security -->
    <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>

</web-app>

    <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.xsd
    http://www.springframework.org/schema/security
    http://www.springframework.org/schema/security/spring-security.xsd">

   <!-- enable use-expressions -->
    <http auto-config="true" use-expressions="true">

        <intercept-url pattern="/admin**" access="hasRole('ROLE_ADMIN')" />

        <!-- access denied page -->
        <access-denied-handler error-page="/403" />

        <form-login
            login-page="/login"
            default-target-url="/welcome"
            authentication-failure-url="/login?error"
            username-parameter="username"
            password-parameter="password" />
        <logout logout-success-url="/login?logout"  />
        <!-- enable csrf protection -->
        <csrf/>
    </http>

    <!-- Select users and user_roles from database -->
    <authentication-manager>
        <authentication-provider>
            <jdbc-user-service data-source-ref="dataSource"
                users-by-username-query=
                    "select USERNAME as username, PASSWORD as password,'true' as enabled from USERS where USERNAME=?"
                authorities-by-username-query=
                    "select USERNAME as username, ROLE as role from USER_ROLES where USERNAME =?  " />
        </authentication-provider>
    </authentication-manager>

</beans:beans>

    <beans xmlns="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-3.0.xsd">

    <bean id="dataSource"
        class="org.springframework.jdbc.datasource.DriverManagerDataSource">

        <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
        <property name="url" value="jdbc:oracle:thin:@localhost:1521:xe" />
        <property name="username" value="system" />
        <property name="password" value="sekhar" />
    </bean>

</beans>

    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    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-3.0.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <context:component-scan base-package="com.mkyong.*" />

    <bean id="viewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/view/" />
        <property name="suffix" value=".jsp" />
    </bean>

</beans>



    import org.springframework.security.authentication.AnonymousAuthenticationToken;
    import org.springframework.security.core.Authentication;
    import org.springframework.security.core.context.SecurityContextHolder;
    import org.springframework.security.core.userdetails.UserDetails;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    import org.springframework.web.bind.annotation.RequestParam;
    import org.springframework.web.servlet.ModelAndView;

    @Controller
    public class MainController {

        @RequestMapping(value = { "/", "/welcome**" }, method = RequestMethod.GET)
        public ModelAndView defaultPage() {

            ModelAndView model = new ModelAndView();
            model.addObject("title", "Spring Security Login Form - Database Authentication");
            model.addObject("message", "This is default page!");
            model.setViewName("hello");
            return model;

        }

        @RequestMapping(value = "/admin**", method = RequestMethod.GET)
        public ModelAndView adminPage() {

            ModelAndView model = new ModelAndView();
            model.addObject("title", "Spring Security Login Form - Database Authentication");
            model.addObject("message", "This page is for ROLE_ADMIN only!");
            model.setViewName("admin");

            return model;

        }

        @RequestMapping(value = "/login", method = RequestMethod.GET)
        public ModelAndView login(@RequestParam(value = "error", required = false) String error,
                @RequestParam(value = "logout", required = false) String logout) {

            ModelAndView model = new ModelAndView();
            if (error != null) {
                model.addObject("error", "Invalid username and password!");
            }

            if (logout != null) {
                model.addObject("msg", "You've been logged out successfully.");
            }
            model.setViewName("login");

            return model;

        }

        //for 403 access denied page
        @RequestMapping(value = "/403", method = RequestMethod.GET)
        public ModelAndView accesssDenied() {

            ModelAndView model = new ModelAndView();

            //check if user is login
            Authentication auth = SecurityContextHolder.getContext().getAuthentication();
            if (!(auth instanceof AnonymousAuthenticationToken)) {
                UserDetails userDetail = (UserDetails) auth.getPrincipal();
                System.out.println(userDetail);

                model.addObject("username", userDetail.getUsername());

            }

            model.setViewName("403");
            return model;

        }

    }

警告如下所示:

     Apr 21, 2017 9:05:31 AM org.apache.tomcat.util.digester.SetPropertiesRule begin WARNING:

[SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Vendorapp'

did not find a matching property. Apr 21, 2017 9:05:31 AM org.apache.tomcat.util.digester.SetPropertiesRule begin WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:SpringSecurityDemo' did not find a matching property. Apr 21, 2017 9:05:31 AM org.apache.catalina.startup.VersionLoggerListener log INFO: Server version: Apache Tomcat/8.0.33 Apr 21, 2017 9:05:31 AM org.apache.catalina.startup.VersionLoggerListener log INFO: Server built: Mar 18 2016 20:31:49 UTC Apr 21, 2017 9:05:31 AM org.apache.catalina.startup.VersionLoggerListener log INFO: Server number: 8.0.33.0 Apr 21, 2017 9:05:31 AM org.apache.catalina.startup.VersionLoggerListener log INFO: OS Name: Windows 10 Apr 21, 2017 9:05:31 AM org.apache.catalina.startup.VersionLoggerListener log INFO: OS Version: 10.0 Apr 21, 2017 9:05:31 AM org.apache.catalina.startup.VersionLoggerListener log INFO: Architecture: amd64 Apr 21, 2017 9:05:31 AM org.apache.catalina.startup.VersionLoggerListener log INFO: Java Home: C:\Program Files\Java\jdk1.8.0_91\jre Apr 21, 2017 9:05:31 AM org.apache.catalina.startup.VersionLoggerListener log INFO: JVM Version: 1.8.0_91-b14 Apr 21, 2017 9:05:31 AM org.apache.catalina.startup.VersionLoggerListener log INFO: JVM Vendor: Oracle Corporation Apr 21, 2017 9:05:31 AM org.apache.catalina.startup.VersionLoggerListener log INFO: CATALINA_BASE: C:\dummy.metadata.plugins\org.eclipse.wst.server.core\tmp1 Apr 21, 2017 9:05:31 AM org.apache.catalina.startup.VersionLoggerListener log INFO: CATALINA_HOME: F:\Tomcat8.0 Apr 21, 2017 9:05:31 AM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dcatalina.base=C:\dummy.metadata.plugins\org.eclipse.wst.server.core\tmp1 Apr 21, 2017 9:05:31 AM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dcatalina.home=F:\Tomcat8.0 Apr 21, 2017 9:05:31 AM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dwtp.deploy=C:\dummy.metadata.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps Apr 21, 2017 9:05:31 AM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Djava.endorsed.dirs=F:\Tomcat8.0\endorsed Apr 21, 2017 9:05:31 AM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dfile.encoding=Cp1252 Apr 21, 2017 9:05:31 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.8.0_91\jre\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jre1.8.0_91/bin/server;C:/Program Files/Java/jre1.8.0_91/bin;C:/Program Files/Java/jre1.8.0_91/lib/amd64;F:\oraclexe\app\oracle\product\11.2.0\server\bin;C:\ProgramData\Oracle\Java\javapath;C:\oraclexe\app\oracle\product\11.2.0\server\bin;C:\app\product\12.1.0\dbhome_1\bin;C:\Program Files (x86)\Java\jdk1.8.0_65\bin;C:\Program Files (x86)\Intel\TXE Components\TCS\;C:\Program Files\Intel\TXE Components\TCS\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\apache-ant-1.9.7\bin;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Program Files (x86)\Skype\Phone\;C:\Users\GUNA SEKHAR\AppData\Local\Microsoft\WindowsApps;C:\apache-maven-3.2.2\bin;C:\eclipse mars.2;;. Apr 21, 2017 9:05:32 AM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["http-nio-7070"] Apr 21, 2017 9:05:32 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector INFO: Using a shared selector for servlet write/read Apr 21, 2017 9:05:32 AM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["ajp-nio-8009"] Apr 21, 2017 9:05:32 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector INFO: Using a shared selector for servlet write/read Apr 21, 2017 9:05:32 AM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 1798 ms Apr 21, 2017 9:05:32 AM org.apache.catalina.core.StandardService startInternal INFO: Starting service Catalina Apr 21, 2017 9:05:32 AM org.apache.catalina.core.StandardEngine startInternal INFO: Starting Servlet Engine: Apache Tomcat/8.0.33 Apr 21, 2017 9:05:33 AM org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [204] milliseconds. Apr 21, 2017 9:05:42 AM org.apache.jasper.servlet.TldScanner scanJars INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. Apr 21, 2017 9:05:42 AM org.apache.catalina.core.ApplicationContext log INFO: No Spring WebApplicationInitializer types detected on classpath Apr 21, 2017 9:05:42 AM org.apache.catalina.core.ApplicationContext log INFO: Initializing Spring root WebApplicationContext Apr 21, 2017 9:05:42 AM org.springframework.web.context.ContextLoader initWebApplicationContext INFO: Root WebApplicationContext: initialization started Apr 21, 2017 9:05:43 AM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh INFO: Refreshing Root WebApplicationContext: startup date [Fri Apr 21 09:05:43 IST 2017]; root of context hierarchy Apr 21, 2017 9:05:43 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/spring-security.xml] Apr 21, 2017 9:05:44 AM org.springframework.security.core.SpringSecurityCoreVersion performVersionChecks INFO: You are running with Spring Security Core 4.2.1.RELEASE Apr 21, 2017 9:05:44 AM org.springframework.security.core.SpringSecurityCoreVersion performVersionChecks WARNING: **** You are advised to use Spring 4.3.5.RELEASE or later with this version. You are running: 4.3.4.RELEASE Apr 21, 2017 9:05:44 AM org.springframework.security.config.SecurityNamespaceHandler INFO: Spring Security 'config' module version is 4.2.1.RELEASE Apr 21, 2017 9:05:44 AM org.springframework.security.config.http.FilterInvocationSecurityMetadataSourceParser parseInterceptUrlsForFilterInvocationRequestMap INFO: Creating access control expression attribute 'hasRole('ROLE_ADMIN')' for /admin** Apr 21, 2017 9:05:44 AM org.springframework.security.config.http.HttpSecurityBeanDefinitionParser checkFilterChainOrder INFO: Checking sorted filter chain: [Root bean: class [org.springframework.security.web.context.SecurityContextPersistenceFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 200, Root bean: class [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 400, Root bean: class [org.springframework.security.web.header.HeaderWriterFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 500, Root bean: class [org.springframework.security.web.csrf.CsrfFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 700, Root bean: class [org.springframework.security.web.authentication.logout.LogoutFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 800, , order = 1200, Root bean: class [org.springframework.security.web.authentication.www.BasicAuthenticationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 1600, Root bean: class [org.springframework.security.web.savedrequest.RequestCacheAwareFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 1700, Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.security.config.http.HttpConfigurationBuilder$SecurityContextHolderAwareRequestFilterBeanFactory#0; factoryMethodName=getBean; initMethodName=null; destroyMethodName=null, order = 1800, Root bean: class [org.springframework.security.web.authentication.AnonymousAuthenticationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 2100, Root bean: class [org.springframework.security.web.session.SessionManagementFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 2200, Root bean: class [org.springframework.security.web.access.ExceptionTranslationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 2300, , order = 2400] Apr 21, 2017 9:05:44 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/spring-database.xml] Apr 21, 2017 9:05:45 AM org.springframework.jdbc.datasource.DriverManagerDataSource setDriverClassName INFO: Loaded JDBC driver: oracle.jdbc.driver.OracleDriver Apr 21, 2017 9:05:46 AM org.springframework.security.provisioning.JdbcUserDetailsManager initDao INFO: No authentication manager set. Reauthentication of users when changing passwords will not be performed. Apr 21, 2017 9:05:46 AM org.springframework.security.web.DefaultSecurityFilterChain INFO: Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher@1, [org.springframework.security.web.context.SecurityContextPersistenceFilter@65fc7ca7, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@c00f385, org.springframework.security.web.header.HeaderWriterFilter@64d14919, org.springframework.security.web.csrf.CsrfFilter@61507925, org.springframework.security.web.authentication.logout.LogoutFilter@674f28ec, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@6cd8635b, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@2af7658, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@60d4ae79, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@7ec2e2c7, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@51af94ff, org.springframework.security.web.session.SessionManagementFilter@284b2524, org.springframework.security.web.access.ExceptionTranslationFilter@6d29e132, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@494f28a] Apr 21, 2017 9:05:46 AM org.springframework.security.config.http.DefaultFilterChainValidator checkLoginPageIsntProtected INFO: Checking whether login URL '/login' is accessible with your configuration Apr 21, 2017 9:05:46 AM org.springframework.web.context.ContextLoader initWebApplicationContext INFO: Root WebApplicationContext: initialization completed in 3774 ms Apr 21, 2017 9:05:46 AM org.apache.catalina.core.ApplicationContext log INFO: Initializing Spring FrameworkServlet 'mvc-dispatcher' Apr 21, 2017 9:05:46 AM org.springframework.web.servlet.DispatcherServlet initServletBean INFO: FrameworkServlet 'mvc-dispatcher': initialization started Apr 21, 2017 9:05:46 AM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh INFO: Refreshing WebApplicationContext for namespace 'mvc-dispatcher-servlet': startup date [Fri Apr 21 09:05:46 IST 2017]; parent: Root WebApplicationContext Apr 21, 2017 9:05:46 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml] Apr 21, 2017 9:05:47 AM org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor INFO: JSR-330 'javax.inject.Inject' annotation found and supported for autowiring Apr 21, 2017 9:05:47 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler INFO: Mapped URL path [/login] onto handler 'mainController' Apr 21, 2017 9:05:47 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler INFO: Mapped URL path [/login.*] onto handler 'mainController' Apr 21, 2017 9:05:47 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler INFO: Mapped URL path [/login/] onto handler 'mainController' Apr 21, 2017 9:05:47 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler INFO: Root mapping to handler 'mainController' Apr 21, 2017 9:05:47 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler INFO: Mapped URL path [/welcome**] onto handler 'mainController' Apr 21, 2017 9:05:47 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler INFO: Mapped URL path [/welcome**.*] onto handler 'mainController' Apr 21, 2017 9:05:47 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler INFO: Mapped URL path [/welcome**/] onto handler 'mainController' Apr 21, 2017 9:05:47 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler INFO: Mapped URL path [/admin**] onto handler 'mainController' Apr 21, 2017 9:05:47 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler INFO: Mapped URL path [/admin**.*] onto handler 'mainController' Apr 21, 2017 9:05:47 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler INFO: Mapped URL path [/admin**/] onto handler 'mainController' Apr 21, 2017 9:05:47 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler INFO: Mapped URL path [/403] onto handler 'mainController' Apr 21, 2017 9:05:47 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler INFO: Mapped URL path [/403.*] onto handler 'mainController' Apr 21, 2017 9:05:47 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler INFO: Mapped URL path [/403/] onto handler 'mainController' Apr 21, 2017 9:05:48 AM org.springframework.web.servlet.DispatcherServlet initServletBean INFO: FrameworkServlet 'mvc-dispatcher': initialization completed in 1592 ms Apr 21, 2017 9:05:55 AM org.apache.jasper.servlet.TldScanner scanJars INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. Apr 21, 2017 9:05:56 AM org.apache.catalina.core.ApplicationContext log INFO: No Spring WebApplicationInitializer types detected on classpath Apr 21, 2017 9:05:56 AM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["http-nio-7070"] Apr 21, 2017 9:05:56 AM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["ajp-nio-8009"] Apr 21, 2017 9:05:56 AM org.apache.catalina.startup.Catalina start INFO: Server startup in 23755 ms Apr 21, 2017 9:06:07 AM org.springframework.web.servlet.PageNotFound noHandlerFound WARNING: No mapping found for HTTP request with URI [/SpringSecurityDemo/j_spring_security_check] in DispatcherServlet with name 'mvc-dispatcher'

我正在使用oracle 11g数据库,登录时出现此错误。请告诉我怎么解决。 我创建了一个如下所示的数据库

create table users(username varchar(90) primary key, password varchar(90), enabled smallint default 1);

create table user_roles(user_role_id int,username varchar(90) not null , role varchar(90) not null, constraint fk_username foreign key(username) references users(username),constraint user_role_pk primary key(user_role_id));

create sequence user_role_pk start with 1;
insert into users values('abc','123456',1);
insert into users values(2,'alex','123456');
insert into user_roles(username, role,user_role_id) values('abc','ROLE_ADMIN',1);

insert into user_roles values(2,'alex','ROLE_USER');

这种说法有什么不对


共 (1) 个答案

  1. # 1 楼答案

    你真的用这种方式配置了SpringSecurityFilterChain

    <!  Spring Security  >
        <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>
    

    如果是这样,请尝试以下方式配置<filter-mapping>

        <filter-mapping>
            <filter-name>springSecurityFilterChain</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>