no handler method in class.....
這篇文章的來源於最近新學習的springmvc遇到的問題如上,其實本身感覺springmvc並不是很難,但是苦於學習方法不得勁,就只好看着幫助文檔和別人寫的小例子了。看完別人的小例子照着helloworld跑出來了,但是感覺不明所以,所以我就先放棄了使用註解,全過程使用最原始的XML配置
<!--多方法解析器-->
<bean id="parameterMethodNameResolver" class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver">
<property name="paramName" value="method"/>
</bean>
<!-- action代理類 -->
<bean id="student" class="org.springframework.web.servlet.mvc.multiaction.MultiActionController">
<property name="methodNameResolver" ref="parameterMethodNameResolver"/>
<property name="delegate" ref="studentController"/>
</bean>
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="stu.do">student</prop>
</props>
</property>
</bean>
錯誤原因是因爲注入delegate的時候它會檢查action裏邊的請求方法是不是含有(HttpServletRequest,HttpServletResponse)沒有就會拋出異常