下面是我的配置。。不知道为什么老报错。。求大侠指教
springmvc-servlet.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-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd"> <context:component-scan base-package="com.soft.console.controller" use-default-filters="false"> <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/> </context:component-scan> <!--启动Spring MVC的注解功能,完成请求和注解POJO的映射 --> <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/> <!-- 缺省的url-bean映射方式 <bean id="defaultHandlerMapping" class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"> <property name="order" value="0"/> </bean>--> <bean id="viewMappings" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <!-- /shopping.do 请求由 flowController 来处理 --> <property name="mappings"> <value> /shopping.htm=flowController </value> </property> <property name="defaultHandler"> <!-- UrlFilenameViewController 会将 "/index" 这样的请求映射成名为 "index" 的视图 --> <bean class="org.springframework.web.servlet.mvc.UrlFilenameViewController"/> </property> </bean> <bean id="flowController" class="org.springframework.webflow.mvc.servlet.FlowController"> <property name="flowExecutor" ref="flowExecutor"/> </bean> <bean id="hessianHandler" class="org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter"></bean> <!-- 第二种:velocity模板配置 --> <!-- InternalResourceViewResolver会在ModelAndView返回的视图名前加上prefix指定的前缀,再在最后加上suffix指定的后缀 --> <!-- 由于UserController返回的ModelAndView中的视图名是userlist,故该视图解析器将在/WEB-INF/jsp/userlist.jsp处查找视图 --> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> <property name="prefix" value="resource/"/> <property name="suffix" value=".jsp"/> </bean> </beans>springwebflot-servlet.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:webflow="http://www.springframework.org/schema/webflow-config" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/webflow-config http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd"> <webflow:flow-executor id="flowExecutor"/> <!--所有 flow 定义文件位置在此配置, flow-builder-services 用于配置 flow 的特性--> <webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices"> <webflow:flow-location path="flows/shopping.xml" id="shopping"/> </webflow:flow-registry> <!--Web Flow 中的视图通过 MVC 框架的视图技术来呈现 --> <webflow:flow-builder-services id="flowBuilderServices" view-factory-creator="mvcViewFactoryCreator"/> <!--指明 MVC 框架的 view resolver ,用于通过 view 名查找资源 --> <bean id="mvcViewFactoryCreator" class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator"> <property name="viewResolvers" ref="viewResolver"/> </bean> </beans>
我在applicationContext.xml中已经加入springwebflot-servlet.xml了
下面是我的目录
我启动时正常,在index页面里面写了<h1>Hello!</h1><br/> <a Cart</a>
启动正常。。。。
运行之后报错:
2013-1-23 14:01:15 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() for servlet [springmvc] in context with path [/DbUtils] threw exception [No adapter for handler [org.springframework.web.servlet.mvc.UrlFilenameViewController@1f12af8]: Does your handler implement a supported interface like Controller?] with root cause javax.servlet.ServletException: No adapter for handler [org.springframework.web.servlet.mvc.UrlFilenameViewController@1f12af8]: Does your handler implement a supported interface like Controller? at org.springframework.web.servlet.DispatcherServlet.getHandlerAdapter(DispatcherServlet.java:1100) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:893) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778) at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:300) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) at java.lang.Thread.run(Thread.java:619)
这个不是webflow的问题,是mvc的问题
太久没有弄这个,只对比了一下我以前的配置,你少了:
<beanclass="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"/>
多了:
<propertyname="defaultHandler"> <!--UrlFilenameViewController会将"/index"这样的请求映射成名为"index"的视图--> |
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。