javax.servlet.ServletException: No adapter for handler
问题描述:
我的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的更多相关文章
- 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 ...
- web项目——javax.servlet.ServletException: Circular view path [registerForm]
报错: 控制台输出: 三月 21, 2019 10:12:32 上午 org.springframework.web.servlet.PageNotFound noHandlerFound 警告: N ...
- javax.servlet.ServletException cannot be resolved to a type错误解决方法
在页面中使用全局路径时${pageContext.request.contextPath}出现javax.servlet.ServletException cannot be resolved to ...
- 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 ...
- javax.servlet.ServletException: java.lang.LinkageError: loader constraint violation:
javax.servlet.ServletException: java.lang.LinkageError: loader constraint violation: when resolving ...
- javax.servlet.ServletException: com.microsoft.jdbc.base.BaseDatabaseMetaData.supportsGetGeneratedKeys()Z
javax.servlet.ServletException: com.microsoft.jdbc.base.BaseDatabaseMetaData.supportsGetGeneratedKey ...
- 报javax.servlet.ServletException: Servlet.init() for servlet springmvc threw exception异常 的解决方案
后台错误信息如下: javax.servlet.ServletException: Servlet.init() for servlet springmvc threw exception org.a ...
- javax.servlet.ServletException: Error instantiating servlet class Compiler 错误
javax.servlet.ServletException: Error instantiating servlet class Compiler org.apache.catalina.authe ...
- HTTP Status 500 - javax.servlet.ServletException
运行某个jsp页面时提示 type Exception report message javax.servlet.ServletException: java.lang.NoClassDefFound ...
随机推荐
- 每日CSS_仿苹果平滑开关按钮
每日CSS_仿苹果平滑开关按钮 2020_12_24 源码 1. 代码解析 1.1 html 代码解析 <div class="checkbox"> <div c ...
- 1.Redis基础命令
重要概念 redis是单线程模型,所有命令都会进入一个队列,然后依次被执行. 全局命令 >>>select dbindex #切换数据库,默认有16个库,库标识符为0-15 > ...
- 安装Yii2框架
一.Windows安装Yii2 1.安装Composer Composer 需要 PHP 5.3.2+ 以上版本,且需要开启 openssl,打开 php 目录下的 php.ini,将 extensi ...
- ajax上传单个文件
jsp页面 <%@ page language="java" pageEncoding="UTF-8"%> <!DOCTYPE HTML> ...
- easyui中刷新列表
<table class="crud-content-info" id="showProductDialogFormstandrad"> </ ...
- Error running 'DemoApplication': No jdk for module 'demo' 没有jdk
方案1----- 按理说jdk都是在File->Project Structure里面设置就可以了,而且现在检查了也是没有问题 后来几经折腾,通过直接搜索Settings里面的jdk,发现还有这 ...
- Java学习日报7.31
package bank;import java.util.*;public class Bank { private Scanner sc=new Scanner(System.in); priva ...
- Centos7无网络下安装mysql5.7——mysql-rpm安装
本教程指将mysql安装到系统默认目录下,如想自定义修改目录,请在rpm安装时自行修改: rpm -ivh --prefix= /opt xxx.rpm #将xxx.rpm安装到/opt下 一.下载m ...
- java容器-Collection
1.介绍 collection<E>是java中容器的最主要的接口,该接口继承于Iterable<E>,使得java中所有实现Collection<E>的容器 ...
- 园子的品牌专区上新:NoSQL 数据库佼佼者 Aerospike
品牌专区是园子去年推出的新楼盘,为优秀的科技企业在园子里提供一个地方,展示自己的品牌,分享自己的技术内容. 最近我们和国外领先的 NoSQL 数据库厂商 Aerospike 达成了合作,入驻了园子的品 ...