【问题标题】:No mapping found for HTTP request with URI [***] in DispatcherServlet在 DispatcherServlet 中找不到带有 URI [***] 的 HTTP 请求的映射
【发布时间】:2017-09-17 22:25:24
【问题描述】:

这是我的代码。我不知道这有什么问题。

<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} 设置 属性 'source' 到 'org.eclipse.jst.jee.server:Vendorapp'

没有找到匹配的属性。 2017 年 4 月 21 日上午 9:05:31 org.apache.tomcat.util.digester.SetPropertiesRule 开始 警告:[SetPropertiesRule]{Server/Service/Engine/Host/Context} 将属性“源”设置为 'org.eclipse.jst.jee.server:SpringSecurityDemo' 没有找到 匹配属性。 2017 年 4 月 21 日上午 9:05:31 org.apache.catalina.startup.VersionLoggerListener 日志 信息:服务器版本:Apache Tomcat/8.0.33 2017 年 4 月 21 日上午 9:05:31 org.apache.catalina.startup.VersionLoggerListener 日志 信息:服务器构建:2016 年 3 月 18 日 20:31:49 UTC 2017 年 4 月 21 日上午 9:05:31 org.apache.catalina.startup.VersionLoggerListener 日志 信息:服务器编号:8.0.33.0 2017 年 4 月 21 日上午 9:05:31 org.apache.catalina.startup.VersionLoggerListener 日志 信息:操作系统名称:Windows 10 2017 年 4 月 21 日上午 9:05:31 org.apache.catalina.startup.VersionLoggerListener 日志 信息:操作系统版本:10.0 2017 年 4 月 21 日上午 9:05:31 org.apache.catalina.startup.VersionLoggerListener 日志 信息:架构:amd64 2017 年 4 月 21 日上午 9:05:31 org.apache.catalina.startup.VersionLoggerListener 日志 信息:Java 主页:C:\Program Files\Java\jdk1.8.0_91\jre 2017 年 4 月 21 日上午 9:05:31 org.apache.catalina.startup.VersionLoggerListener 日志 信息:JVM 版本:1.8.0_91-b14 2017 年 4 月 21 日上午 9:05:31 org.apache.catalina.startup.VersionLoggerListener 日志 信息:JVM 供应商:甲骨文公司 2017 年 4 月 21 日上午 9:05:31 org.apache.catalina.startup.VersionLoggerListener 日志 信息:CATALINA_BASE:C:\dummy.metadata.plugins\org.eclipse.wst.server.core\tmp1 2017 年 4 月 21 日上午 9:05:31 org.apache.catalina.startup.VersionLoggerListener 日志 信息:CATALINA_HOME:F:\Tomcat8.0 2017 年 4 月 21 日上午 9:05:31 org.apache.catalina.startup.VersionLoggerListener 日志 信息:命令行参数:-Dcatalina.base=C:\dummy.metadata.plugins\org.eclipse.wst.server.core\tmp1 2017 年 4 月 21 日上午 9:05:31 org.apache.catalina.startup.VersionLoggerListener 日志 信息:命令行参数:-Dcatalina.home=F:\Tomcat8.0 2017 年 4 月 21 日上午 9:05:31 org.apache.catalina.startup.VersionLoggerListener 日志 信息:命令行参数:-Dwtp.deploy=C:\dummy.metadata.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps 2017 年 4 月 21 日上午 9:05:31 org.apache.catalina.startup.VersionLoggerListener 日志 信息:命令行参数:-Djava.endorsed.dirs=F:\Tomcat8.0\endorsed 2017 年 4 月 21 日上午 9:05:31 org.apache.catalina.startup.VersionLoggerListener 日志 信息:命令行参数:-Dfile.encoding=Cp1252 2017 年 4 月 21 日上午 9:05:31 org.apache.catalina.core.AprLifecycleListener 生命周期事件 信息:在生产环境中未找到基于 APR 的 Apache Tomcat Native 库,该库允许在生产环境中获得最佳性能 java.library.path: C:\Program 文件\Java\jdk1.8.0_91\jre\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program 文件/Java/jre1.8.0_91/bin/server;C:/Program 文件/Java/jre1.8.0_91/bin;C:/Program 文件/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 文件 (x86)\Java\jdk1.8.0_65\bin;C:\Program Files (x86)\Intel\TXE 组件\TCS\;C:\Program Files\Intel\TXE 组件\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 文件 (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program 文件\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL 服务器\120\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL 服务器\120\DTS\Binn\;C:\apache-ant-1.9.7\bin;C:\Program 文件\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program 文件\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 火星.2;;. 2017 年 4 月 21 日上午 9:05:32 org.apache.coyote.AbstractProtocol 初始化 信息:初始化 ProtocolHandler ["http-nio-7070"] 2017 年 4 月 21 日上午 9:05:32 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector 信息:使用共享选择器进行 servlet 写入/读取 2017 年 4 月 21 日上午 9:05:32 org.apache.coyote.AbstractProtocol 初始化 信息:初始化 ProtocolHandler ["ajp-nio-8009"] 2017 年 4 月 21 日上午 9:05:32 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector 信息:使用共享选择器进行 servlet 写入/读取 2017 年 4 月 21 日上午 9:05:32 org.apache.catalina.startup.Catalina 加载 INFO:初始化处理时间为 1798 毫秒 2017 年 4 月 21 日上午 9:05:32 org.apache.catalina.core.StandardService startInternal 信息:启动服务 Catalina 2017 年 4 月 21 日上午 9:05:32 org.apache.catalina.core.StandardEngine startInternal 信息:启动 Servlet 引擎:Apache Tomcat/8.0.33 2017 年 4 月 21 日上午 9:05:33 org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom 信息:使用 [SHA1PRNG] 为会话 ID 生成创建 SecureRandom 实例花费了 [204] 毫秒。 2017 年 4 月 21 日上午 9:05:42 org.apache.jasper.servlet.TldScanner scanJars 信息:至少有一个 JAR 已扫描 TLD,但未包含 TLD。为此记录器启用调试日志记录以获取 JAR 的完整列表 那 已扫描但未在其中找到 TLD。跳过不需要的 JAR 在扫描期间可以提高启动时间和 JSP 编译时间。 2017 年 4 月 21 日上午 9:05:42 org.apache.catalina.core.ApplicationContext 日志 信息:在类路径上未检测到 Spring WebApplicationInitializer 类型 2017 年 4 月 21 日上午 9:05:42 org.apache.catalina.core.ApplicationContext 日志 信息:初始化 Spring 根 WebApplicationContext 2017 年 4 月 21 日上午 9:05:42 org.springframework.web.context.ContextLoader 初始化WebApplicationContext INFO: Root WebApplicationContext: 初始化开始 2017 年 4 月 21 日上午 9:05:43 org.springframework.web.context.support.XmlWebApplicationContext 准备刷新 信息:刷新根 WebApplicationContext:启动日期 [Fri Apr 21 09:05:43 IST 2017];上下文层次的根 2017 年 4 月 21 日上午 9:05:43 org.springframework.beans.factory.xml.XmlBeanDefinitionReader 加载Bean定义 信息:从 ServletContext 资源 [/WEB-INF/spring-security.xml] 加载 XML bean 定义 2017 年 4 月 21 日上午 9:05:44 org.springframework.security.core.SpringSecurityCoreVersion 执行版本检查 信息:您正在使用 Spring Security Core 4.2.1.RELEASE 运行 2017 年 4 月 21 日上午 9:05:44 org.springframework.security.core.SpringSecurityCoreVersion 执行版本检查 警告:**** 建议您在此版本中使用 Spring 4.3.5.RELEASE 或更高版本。您正在运行:4.3.4.RELEASE 2017 年 4 月 21 日上午 9:05:44 org.springframework.security.config.SecurityNamespaceHandler 信息:Spring Security 'config' 模块版本是 4.2.1.RELEASE 2017 年 4 月 21 日上午 9:05:44 org.springframework.security.config.http.FilterInvocationSecurityMetadataSourceParser parseInterceptUrlsForFilterInvocationRequestMap 信息:为 /admin 创建访问控制表达式属性 'hasRole('ROLE_ADMIN')'** 2017 年 4 月 21 日上午 9:05:44 org.springframework.security.config.http.HttpSecurityBeanDefinitionParser 检查FilterChainOrder 信息:检查排序过滤器链:[根 bean:类 [org.springframework.security.web.context.SecurityContextPersistenceFilter]; 范围=;摘要=假;懒惰初始化=假;自动线模式=0; 依赖检查=0;自动接线候选=真;主要=假; 工厂BeanName=空;工厂方法名=空;初始化方法名=空; destroyMethodName=null, order = 200, 根 bean: 类 [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter]; 范围=;摘要=假;懒惰初始化=假;自动线模式=0; 依赖检查=0;自动接线候选=真;主要=假; 工厂BeanName=空;工厂方法名=空;初始化方法名=空; destroyMethodName=null, order = 400, 根 bean: 类 [org.springframework.security.web.header.HeaderWriterFilter];范围=; 摘要=假;懒惰初始化=假;自动线模式=0;依赖检查=0; 自动接线候选=真;主要=假;工厂BeanName=空; 工厂方法名=空;初始化方法名=空;销毁方法名=空, order = 500,根 bean:类 [org.springframework.security.web.csrf.CsrfFilter];范围=; 摘要=假;懒惰初始化=假;自动线模式=0;依赖检查=0; 自动接线候选=真;主要=假;工厂BeanName=空; 工厂方法名=空;初始化方法名=空;销毁方法名=空, order = 700,根 bean:类 [org.springframework.security.web.authentication.logout.LogoutFilter]; 范围=;摘要=假;懒惰初始化=假;自动线模式=0; 依赖检查=0;自动接线候选=真;主要=假; 工厂BeanName=空;工厂方法名=空;初始化方法名=空; destroyMethodName=null, order = 800, , order = 1200,根 bean:类 [org.springframework.security.web.authentication.www.BasicAuthenticationFilter]; 范围=;摘要=假;懒惰初始化=假;自动线模式=0; 依赖检查=0;自动接线候选=真;主要=假; 工厂BeanName=空;工厂方法名=空;初始化方法名=空; destroyMethodName=null, order = 1600, 根 bean: 类 [org.springframework.security.web.savedrequest.RequestCacheAwareFilter]; 范围=;摘要=假;懒惰初始化=假;自动线模式=0; 依赖检查=0;自动接线候选=真;主要=假; 工厂BeanName=空;工厂方法名=空;初始化方法名=空; destroyMethodName=null, order = 1700, 根 bean: class [null];范围=; 摘要=假;懒惰初始化=假;自动线模式=0;依赖检查=0; 自动接线候选=真;主要=假; factoryBeanName=org.springframework.security.config.http.HttpConfigurationBuilder$SecurityContextHolderAwareRequestFilterBeanFactory#0; 工厂方法名=getBean;初始化方法名=空; destroyMethodName=null, order = 1800, 根 bean: 类 [org.springframework.security.web.authentication.AnonymousAuthenticationFilter]; 范围=;摘要=假;懒惰初始化=假;自动线模式=0; 依赖检查=0;自动接线候选=真;主要=假; 工厂BeanName=空;工厂方法名=空;初始化方法名=空; destroyMethodName=null, order = 2100, 根 bean: 类 [org.springframework.security.web.session.SessionManagementFilter]; 范围=;摘要=假;懒惰初始化=假;自动线模式=0; 依赖检查=0;自动接线候选=真;主要=假; 工厂BeanName=空;工厂方法名=空;初始化方法名=空; destroyMethodName=null, order = 2200, 根 bean: 类 [org.springframework.security.web.access.ExceptionTranslationFilter]; 范围=;摘要=假;懒惰初始化=假;自动线模式=0; 依赖检查=0;自动接线候选=真;主要=假; 工厂BeanName=空;工厂方法名=空;初始化方法名=空; destroyMethodName=null, order = 2300, , 订单 = 2400] 2017 年 4 月 21 日上午 9:05:44 org.springframework.beans.factory.xml.XmlBeanDefinitionReader 加载Bean定义 信息:从 ServletContext 资源 [/WEB-INF/spring-database.xml] 加载 XML bean 定义 2017 年 4 月 21 日上午 9:05:45 org.springframework.jdbc.datasource.DriverManagerDataSource 设置驱动程序类名 信息:加载的 JDBC 驱动程序:oracle.jdbc.driver.OracleDriver 2017 年 4 月 21 日上午 9:05:46 org.springframework.security.provisioning.JdbcUserDetailsManager 初始化道 信息:未设置身份验证管理器。更改密码时不会重新验证用户。 2017 年 4 月 21 日上午 9:05:46 org.springframework.security.web.DefaultSecurityFilterChain 信息:创建过滤器链: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] 2017 年 4 月 21 日上午 9:05:46 org.springframework.security.config.http.DefaultFilterChainValidator checkLoginPageIsntProtected 信息:检查您的配置是否可以访问登录 URL '/login' 2017 年 4 月 21 日上午 9:05:46 org.springframework.web.context.ContextLoader 初始化WebApplicationContext 信息:根 WebApplicationContext:初始化在 3774 毫秒内完成 2017 年 4 月 21 日上午 9:05:46 org.apache.catalina.core.ApplicationContext 日志 信息:初始化 Spring FrameworkServlet 'mvc-dispatcher' 2017 年 4 月 21 日上午 9:05:46 org.springframework.web.servlet.DispatcherServlet initServletBean 信息:FrameworkServlet 'mvc-dispatcher':初始化开始 2017 年 4 月 21 日上午 9:05:46 org.springframework.web.context.support.XmlWebApplicationContext 准备刷新 信息:为命名空间“mvc-dispatcher-servlet”刷新 WebApplicationContext:启动日期 [Fri Apr 21 09:05:46 IST 2017]; 父级:根 WebApplicationContext 2017 年 4 月 21 日上午 9:05:46 org.springframework.beans.factory.xml.XmlBeanDefinitionReader 加载Bean定义 信息:从 ServletContext 资源 [/WEB-INF/mvc-dispatcher-servlet.xml] 加载 XML bean 定义 2017 年 4 月 21 日上午 9:05:47 org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor 信息:找到并支持自动装配 JSR-330 'javax.inject.Inject' 注释 2017 年 4 月 21 日上午 9:05:47 org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping 注册处理程序 信息:将 URL 路径 [/login] 映射到处理程序 'mainController' 2017 年 4 月 21 日上午 9:05:47 org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping 注册处理程序 信息:将 URL 路径 [/login.*] 映射到处理程序 'mainController' 2017 年 4 月 21 日上午 9:05:47 org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping 注册处理程序 信息:将 URL 路径 [/login/] 映射到处理程序 'mainController' 2017 年 4 月 21 日上午 9:05:47 org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping 注册处理程序 信息:到处理程序“mainController”的根映射 2017 年 4 月 21 日上午 9:05:47 org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping 注册处理程序 信息:将 URL 路径 [/welcome**] 映射到处理程序 'mainController' 2017 年 4 月 21 日上午 9:05:47 org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping 注册处理程序 信息:将 URL 路径 [/welcome**.*] 映射到处理程序 'mainController' 2017 年 4 月 21 日上午 9:05:47 org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping 注册处理程序 信息:将 URL 路径 [/welcome**/] 映射到处理程序 'mainController' 2017 年 4 月 21 日上午 9:05:47 org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping 注册处理程序 信息:将 URL 路径 [/admin**] 映射到处理程序 'mainController' 2017 年 4 月 21 日上午 9:05:47 org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping 注册处理程序 信息:将 URL 路径 [/admin**.*] 映射到处理程序 'mainController' 2017 年 4 月 21 日上午 9:05:47 org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping 注册处理程序 信息:将 URL 路径 [/admin**/] 映射到处理程序 'mainController' 2017 年 4 月 21 日上午 9:05:47 org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping 注册处理程序 信息:将 URL 路径 [/403] 映射到处理程序 'mainController' 2017 年 4 月 21 日上午 9:05:47 org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping 注册处理程序 信息:将 URL 路径 [/403.*] 映射到处理程序 'mainController' 2017 年 4 月 21 日上午 9:05:47 org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping 注册处理程序 信息:将 URL 路径 [/403/] 映射到处理程序 'mainController' 2017 年 4 月 21 日上午 9:05:48 org.springframework.web.servlet.DispatcherServlet initServletBean 信息:FrameworkServlet 'mvc-dispatcher':初始化在 1592 毫秒内完成 2017 年 4 月 21 日上午 9:05:55 org.apache.jasper.servlet.TldScanner scanJars 信息:至少有一个 JAR 已扫描 TLD,但未包含 TLD。为此记录器启用调试日志记录以获取 JAR 的完整列表 那 已扫描但未在其中找到 TLD。跳过不需要的 JAR 在扫描期间可以提高启动时间和 JSP 编译时间。 2017 年 4 月 21 日上午 9:05:56 org.apache.catalina.core.ApplicationContext 日志 信息:在类路径上未检测到 Spring WebApplicationInitializer 类型 2017 年 4 月 21 日上午 9:05:56 org.apache.coyote.AbstractProtocol 开始 信息:启动协议处理程序 ["http-nio-7070"] 2017 年 4 月 21 日上午 9:05:56 org.apache.coyote.AbstractProtocol 开始 信息:启动 ProtocolHandler ["ajp-nio-8009"] 2017 年 4 月 21 日上午 9:05:56 org.apache.catalina.startup.Catalina 开始 信息:服务器在 23755 毫秒内启动 2017 年 4 月 21 日上午 9:06:07 org.springframework.web.servlet.PageNotFound noHandlerFound 警告:在 DispatcherServlet 中找不到带有 URI [/SpringSecurityDemo/j_spring_security_check] 的 HTTP 请求的映射 名称为“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');

这句话有什么问题?

【问题讨论】:

  • WARNING: No mapping found for HTTP request with URI [/SpringSecurityDemo/j_spring_security_check] in DispatcherServlet with name 'mvc-dispatcher' 我在使用用户名和密码登录时收到此错误

标签: java spring-mvc oracle11g


【解决方案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>

如果是这样,请尝试以这种方式配置&lt;filter-mapping&gt;

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-06-11
    • 2021-08-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-20
    • 2015-06-03
    • 2023-03-29
    相关资源
    最近更新 更多