惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Privacy & Cybersecurity Law Blog
V
V2EX
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Register - Security
The Register - Security
MongoDB | Blog
MongoDB | Blog
P
Privacy International News Feed
The Last Watchdog
The Last Watchdog
Security Archives - TechRepublic
Security Archives - TechRepublic
美团技术团队
Stack Overflow Blog
Stack Overflow Blog
博客园 - 司徒正美
博客园 - 三生石上(FineUI控件)
V
Visual Studio Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
K
Kaspersky official blog
S
Secure Thoughts
T
Tenable Blog
Security Latest
Security Latest
The Cloudflare Blog
S
Security @ Cisco Blogs
H
Heimdal Security Blog
aimingoo的专栏
aimingoo的专栏
TaoSecurity Blog
TaoSecurity Blog
Blog — PlanetScale
Blog — PlanetScale
Microsoft Security Blog
Microsoft Security Blog
Schneier on Security
Schneier on Security
Webroot Blog
Webroot Blog
G
Google Developers Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Scott Helme
Scott Helme
IT之家
IT之家
Latest news
Latest news
The Hacker News
The Hacker News
C
Check Point Blog
T
The Exploit Database - CXSecurity.com
H
Hackread – Cybersecurity News, Data Breaches, AI and More
腾讯CDC
C
CERT Recently Published Vulnerability Notes
NISL@THU
NISL@THU
N
News | PayPal Newsroom
Forbes - Security
Forbes - Security
P
Palo Alto Networks Blog
S
Security Affairs
S
Securelist
Google Online Security Blog
Google Online Security Blog
WordPress大学
WordPress大学
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
A
About on SuperTechFans

博客园 - foward.molly.宝儿

POI 生成excel(大数据量) SXSSF jenkins和sonar的几个问题 Test class should have exactly one public constructor解决办法 ubuntu安装和查看已安装 rails mysql2问题 axis2依赖的其他jar, 版本不是最新的 mysql: 启动和停止服务 mysql: 安装后的目录结构 msyql: mysql rpm安装手记 - foward.molly.宝儿 velocity: velocty转义html xml等 testng: testng使用小结 IE, firefox竖向 横向滚动条处理 ruby: rdoc生成文档的好工具 spring: 一些基本配置--也许只有自己能够读懂 - foward.molly.宝儿 - 博客园 maven: maven创建工程,web工程等-普通java app, web app maven: maven编译时指定maven库,即指定profile ssh免密码登录, 发送命令到多个Linux php: eclipse 编辑 php ruby: 使用netbeans debug ruby
spring: web学习笔记1--异常处理:No adapter for handler - foward.molly.宝儿
foward.molly · 2010-08-31 · via 博客园 - foward.molly.宝儿

在配置spring web框架的时候,遇到No adapter for handler的异常

前置过程:

自己想实现两种方式的bean的解析,一种是通过手动配置的

即要通过写 <bean id="xxxx" class="xx.xxx.ccc"/>

第二种是通过注解方式实现的

即在public class xxx上面加个注释@Controller,然后又不想在这个地方写上@RequestMapping("/xxx.htm"),即不想把这个请求的url写死,想根据controller的name来自动解析

然后就基本卡壳在这个解析上面了,两种方式都不能很好的兼容。

出现错误的时候的xml是

xxx-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<!-- - DispatcherServlet application context for PetClinic's web tier. -->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi
="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context
="http://www.springframework.org/schema/context"
xmlns:oxm
="http://www.springframework.org/schema/oxm"
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/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd"
><context:component-scan base-package="com.molly"></context:component-scan><bean id="homePageController" class="com.molly.controller.HomePageController">
<property name="rantService" ref="rantService"></property>
</bean>
<bean id="rantService" class="com.molly.service.RantService"></bean>
<bean id="sampleController" class="com.molly.controller.SampleController"></bean><bean id="rantsForVehicle" class="com.molly.controller.RantsForVehicleController">
<property name="rantService" ref="rantService"></property>
</bean><bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
<bean
class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<!-- this bean with the well known name generates view names for us -->
<bean id="viewNameTranslator"
class
="org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator" />
<!-- maps request URLs to Controller names -->
<bean
class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping" />  <!-- - This bean resolves specific types of exceptions to corresponding
logical - view names for error views. The default behaviour of DispatcherServlet
- is to propagate all exceptions to the servlet container: this will happen
- here with all other types of exceptions.
-->
<bean
class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
<props>
<prop key="org.springframework.web.servlet.PageNotFound">pageNotFound</prop>
<prop key="org.springframework.dao.DataAccessException">dataAccessFailure</prop>
<prop key="org.springframework.transaction.TransactionException">dataAccessFailure</prop>
</props>
</property>
</bean><bean id="velocityConfigurer"
class
="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
<property name="configLocation">
<value>/WEB-INF/velocity/velocity.properties</value>
</property>
<property name="resourceLoaderPath">
<value>/WEB-INF/templates/</value>
</property>
<property name="velocityProperties">
<props>
<prop key="directive.foreach.counter.name">
loopCoounter
</prop>
<prop key="directive.foreach.counter.initial.value">
0
</prop>
<prop key="input.encoding">UTF-8</prop>
<prop key="output.encoding">UTF-8</prop>
<prop key="contentType">text/html;charset=UTF-8</prop>
</props>
</property>
</bean><bean id="viewResolver"
class
="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
<property name="suffix">
<value>.vm</value>
</property>
<property name="exposeRequestAttributes">
<value>true</value>
</property>
<property name="exposeSessionAttributes">
<value>true</value>
</property>
<property name="contentType">
<value>text/html;charset=UTF-8</value>
</property>
<!-- <property name="toolboxConfigLocation"> <value>/WEB-INF/velocity/toolbox.xml</value>
</property>
-->
</bean></beans>

出错的地方就是,通过指定bean id的那几个,都不能被访问到,会抛错误出来(这几个是没有@Controller这个注解的,直接实现的controller)

但是写了@controller和@RequestMapping的,都可以正常访问

然后加了两个adapter,就可以了

<bean
class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" />
<bean class="org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter" />

加上这两个bean的处理,就可以用了

参考自google groups:http://groups.google.com/group/gwt-sl/browse_thread/thread/f563b200aa0af307

一点一点搞spring,原理暂时也讲不出个123来,只是暂时解决遇到的问题