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个回答

SimpleUrlHandlerMapping 这个是映射器,楼主还没有配置适配器啊!!!!非注解情况下 适配器可以用http://blog.csdn.net/qq_33727653/article/details/77096723 大体看下,看不明白百度一下

mvc:default-servlet-handler/ 这行加上就行了

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!