为了账号安全,请及时绑定邮箱和手机立即绑定

springmvc 全注解 javax.servlet.ServletException: No adapter for handler异常

springmvc 全注解 javax.servlet.ServletException: No adapter for handler异常

一人我编程累 2019-02-20 16:44:26
<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" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans        http://www.springframework.org/schema/beans/spring-beans.xsd        http://www.springframework.org/schema/context        http://www.springframework.org/schema/context/spring-context.xsd        http://www.springframework.org/schema/aop        http://www.springframework.org/schema/aop/spring-aop.xsd        http://www.springframework.org/schema/mvc        http://www.springframework.org/schema/mvc/spring-mvc.xsd">        <!-- 启用Spring 基于annotation 的DI 使用户可以在Spring MVC中使用Spring的强大功能             激活@Request @Autowired JSR 250's @PostConstruct,@PreDestory and @Resource等标     -->    <context:annotation-config />     <!-- 开启扫描只扫描controlle的注解 --> <context:component-scan base-package="top.yunduo2018.taskchain.controller" />        <!-- 扩充了注解驱动  可以将参数绑定到控制器参数 -->     <mvc:annotation-driven />        <!-- DispatcherServlet不处理静态资源,交给服务器默认的servlet处理 -->    <mvc:default-servlet-handler />     <!-- HandlerMapping  无需配置 SpringMVC默认启动       DefaultAnnotationHandlerMapping  annotation-drivern HandlerMapping    --></beans>controller 层代码package top.yunduo2018.taskchain.controller;import java.util.Map;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.stereotype.Repository;import org.springframework.web.bind.annotation.RequestBody;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import org.springframework.web.bind.annotation.ResponseBody;import top.yunduo2018.taskchain.common.ReturnMessage;import top.yunduo2018.taskchain.entity.UserInfoEntity;import top.yunduo2018.taskchain.service.UserInfoService;@Controller@Repository(value = "/user/*")public class UserInfoController {    @Autowired    UserInfoService userInfoservice;    /*     * 访问路径....项目名/user/userLogin     * post请求     * @param UserInfoEntity实体类的数据类型     * return  Map<String,Object>     * */    @ResponseBody    @RequestMapping(value="userLogin.do",method = RequestMethod.POST)        public  Map<String,Boolean> userLogin(UserInfoEntity user){                boolean res=userInfoservice.isExistUser(user);                return ReturnMessage.returnMsg("success", res);            }        /*     * 访问路径....项目名/user/userRegister     * post请求     * @param UserInfoEntity实体类的数据类型     * return  Map<String,Object>     * */        @ResponseBody    @RequestMapping(value="userRegister.do",method = RequestMethod.POST)    public   String userRegister(UserInfoEntity user){                /*boolean res=userInfoservice.register(user);                return ReturnMessage.returnMsg("success", res);*/                return "success";     }    }tomcat 启动的时候没有报错http://localhost:80/TaskChain/user/userRegister.do 访问接口的时候就报以下异常javax.servlet.ServletException: No adapter for handler [top.yunduo2018.taskchain.controller.UserInfoController@1600c14a]: The DispatcherServlet configuration needs to include a HandlerAdapter that supports this handler at org.springframework.web.servlet.DispatcherServlet.getHandlerAdapter(DispatcherServlet.java:1272) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1021) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:908) at javax.servlet.http.HttpServlet.service(HttpServlet.java:661) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882) at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748)
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 2132 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信