Baymax0532 2017-11-10 01:21 采纳率: 0%
浏览 807

springmvc非注解的方式anddleradapter

搭建框架学习springmvc,用非注解的方式,handdlermapping用的是SimpleUrlHandlerMapping,需要怎么配置handdleradapter
<?xml version="1.0" encoding="UTF-8"?>
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
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
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">

<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    <property name="mappings">
        <props>
            <prop key="/main.html">userController</prop>
        </props>
    </property>
</bean>

<bean id="userController" class="com.walle.user.controller.UserController">
</bean>

<!-- 开启注解 -->
<!-- <mvc:annotation-driven></mvc:annotation-driven> -->

<!-- 扫描包中的注解,注册成bean -->
<!-- <context:component-scan base-package="com.walle"></context:component-scan> -->

<!-- 静态资源 -->
<mvc:resources location="/resources/static/" mapping="/resources/**"></mvc:resources>

<!-- 配置视图解析器 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/pages"></property>
    <property name="suffix" value=".jsp"></property>
</bean>

现在访问localhost:8080/learn_sia/main.html会报错
Servlet.service() for servlet [dispatcher] in context with path [/learn_sia] threw exception [No adapter for handler [com.walle.user.controller.UserController@55d8d551]: The DispatcherServlet configuration needs to include a HandlerAdapter that supports this handler] with root cause
javax.servlet.ServletException: No adapter for handler [com.walle.user.controller.UserController@55d8d551]: The DispatcherServlet configuration needs to include a HandlerAdapter that supports this handler

  • 写回答

3条回答 默认 最新

  • 猿李 2017-11-10 01:33
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器