问题描述:

我的web.xml如下:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<!--前端控制器DispactherServlet-->
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:springmvc.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping> </web-app>

springmvc.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:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!--扫包-->
<context:component-scan base-package="com.courage"></context:component-scan> <!--映射器-->
<bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"></bean>
<!--适配器-->
<bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"></bean>
<bean class="org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter"/>
<!--解析器-->
<bean id="internalResourceViewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="WEB-INF/page/"></property>
<property name="suffix" value=".jsp"></property>
</bean> <bean id="/test01" class="com.courage.controller.FirstController"></bean> </beans>

Controller如下:

package com.courage.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; @Controller
public class FirstController { @RequestMapping("/test01")
public String test01(){
System.out.println("test01");
return "success";
}
}

解决办法:

springmvc.xml中删掉:

 <bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"></bean>
<bean id="/test01" class="com.courage.controller.FirstController"></bean>

springmvc.xml中添加:

<mvc:annotation-driven />

原因:

https://docs.spring.io/spring/docs/current/spring-framework-reference/web.html#mvc

 

javax.servlet.ServletException: No adapter for handler的更多相关文章

  1. javax.servlet.ServletException: Circular view path [index]: would dispatch back to the current handler URL [/pay/index] again. Check your ViewResolver setup!

    2019-08-08 17:12:03.544 ERROR 13748 --- [nio-8080-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Se ...

  2. web项目——javax.servlet.ServletException: Circular view path [registerForm]

    报错: 控制台输出: 三月 21, 2019 10:12:32 上午 org.springframework.web.servlet.PageNotFound noHandlerFound 警告: N ...

  3. javax.servlet.ServletException cannot be resolved to a type错误解决方法

    在页面中使用全局路径时${pageContext.request.contextPath}出现javax.servlet.ServletException cannot be resolved to ...

  4. Spring mvc-异常javax.servlet.ServletException: Could not resolve view with name 'xxx' in servlet with name 'spring'

    最近使用spring mvc开发项目,遇到一个问题: javax.servlet.ServletException: Could not resolve view with name 'ok' in ...

  5. javax.servlet.ServletException: java.lang.LinkageError: loader constraint violation:

    javax.servlet.ServletException: java.lang.LinkageError: loader constraint violation: when resolving ...

  6. javax.servlet.ServletException: com.microsoft.jdbc.base.BaseDatabaseMetaData.supportsGetGeneratedKeys()Z

    javax.servlet.ServletException: com.microsoft.jdbc.base.BaseDatabaseMetaData.supportsGetGeneratedKey ...

  7. 报javax.servlet.ServletException: Servlet.init() for servlet springmvc threw exception异常 的解决方案

    后台错误信息如下: javax.servlet.ServletException: Servlet.init() for servlet springmvc threw exception org.a ...

  8. javax.servlet.ServletException: Error instantiating servlet class Compiler 错误

    javax.servlet.ServletException: Error instantiating servlet class Compiler org.apache.catalina.authe ...

  9. HTTP Status 500 - javax.servlet.ServletException

    运行某个jsp页面时提示 type Exception report message javax.servlet.ServletException: java.lang.NoClassDefFound ...

随机推荐

  1. Java基础-方法的重写和重载

    重载(Overload)和重写(Override) 重载是在同一个类里面,方法名字相同,而参数不同.返回类型可以相同也可以不同.每个重载的方法(或者构造函数)都必须有一个独一无二的参数类型列表. 重写 ...

  2. VS批量添加多个文件

    步骤 1.设置项目,显示所有文件.2.点击项目,右键在资源管理器中打开.3.将要导入的文件复制到对应的文件中去.4.在解决方案中就可以看到刚才添加的多个文件.5.在新加的文件夹上右键,包括在项目中.

  3. PHP7.4.3的BUG导致微信公众号CURl上传文件的412错误

    https://segmentfault.com/q/1010000021407039 升级PHP就好了 https://segmentfault.com/q/1010000021407039

  4. Java基础经典案例

    案例列表 01减肥计划switch版本 02减肥计划if版本 03逢七跳过 04不死神兔 05百钱白鸡 06数组元素求和 07判断两个数组是否相同 08查找元素在数组中的索引 09数组元素反转 10评 ...

  5. python常用操作和内置函数

    一.常用数据处理方法. 1.索引:按照号码将对应位置的数据取出使用 2.list将任意类型数据用逗号分割存在列表中 3.range:产生一堆数字(顾头不顾尾) 4.切片:可以从复制数据的一部分,不影响 ...

  6. 风炫安全web安全学习第三十五节课 文件下载和文件读取漏洞

    风炫安全web安全学习第三十五节课 文件下载和文件读取漏洞 0x03 任意文件下载漏洞 一些网站由于业务需求,往往需要提供文件下载功能,但若对用户下载的文件不做限制,则恶意用户就能够下载任意敏感文件, ...

  7. Blazor VS 传统Web应用程序

    原文作者: Christian Findlay 原文链接: https://christianfindlay.com/2020/07/09/blazor-vs-traditional-web-apps ...

  8. ICMP协议概述

    • ICMP是三层协议,和IP.ARP.ICMP同属三层    • IP协议中的6是代表上层的TCP协议,17代表UDP协议,1代表同层的ICMP协议    • ICMP协议主要用来探测       ...

  9. C语言的类型大小

    C语言的类型大小 设计程序的时候我们一般会考虑的尽量的周全,尤其是像C这样的静态类型语言. 有一些溢出的问题就源于没有搞清楚变量的大小范围,所以我们编写的时候需要特别注意 C的整形(整数类型)大小 C ...

  10. 想学Python不知如何入门,教你!

    一.入门引导   想必有很多小伙伴想学习Python,又不知道如何入门,总觉得学习一定要头悬梁,锥刺股!NO,今天给大家分享下如何轻松入门Python!   首先,我们要学习Python,那一定要和你 ...