關於springmvc一個控制器多個方法非註解的請求映射

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)沒有就會拋出異常

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章