Framework/Spring

No request handling method with name 'form' in class 에러!!

FreeEnd 2011. 11. 10. 16:42
반응형

환경

WAS : tomcat 7.0
환경 : JDK 1.6, SPRING 3.0


문제발생!!
 
 아. 아직도 오장 육부가 뒤집힌다. 얼마전부터 서프라이즈 하게 혼자 뭣좀 해보려구 개발 환경 하나 잡고 있다. 벌써 오래전부터 준비해온 일이지만, 매번 이 시동거는게 힘들어 매번 빈둥거리다가 드디어 몸좀 움직였다.

 이클립스 다운받구, JDK받아 환경 잡구, 프로젝트 만들어 spring 3.0 라이브러리 넣고.. 작업준비를 끝내고.. web.xml 설정에 들어갔다. 뭐 내가 익숙한하게 ContextConfig환경 잡고.. 컨트롤러는 멀티액션 컨트롤러로....
자자. 환경 설정도 끝났다. 그리고 테스트 Controller 만들어서 호출하는 순간!!! 에러발생. 분명 파라메터로 method 잘 날려줬구.. 설정도 이상이 없었는데... 문제는 하나도 없었다. 설정문제는 아닌듯한데.. 일단 에러는 다음과 같다.
 

2011. 11. 10 오후 4:15:17 org.springframework.web.servlet.mvc.multiaction.MultiActionController handleNoSuchRequestHandlingMethod
경고: No request handling method with name 'form' in class [com.freeend.web.test.TestController]


  어라. 다시보니 에러도 아니고 경고.. 우라질. 메소드를 못찾는데 경고냐. 에러지. 썅.
여튼 문제 계속 찾아봤다.
 


원인탐색

 우선 에러 메시지는 이런 의미이다. MultiActionController가 파라메터로 받은 method 값을 이용해 해당 요청이 원하는 Controller의 메소드를 찾았지만 해당 메소드를 찾을수 없다는 에러이다. 

난 완벽하지만 혹시나.  자. 설정을 다시 확인했다.

 
web.xml 

<context-param>     
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/spring-servlet.xml</param-value>
</context-param>

<servlet-mapping>
    <servlet-name>spring</servlet-name>
    <url-pattern>*.do</url-pattern>
</servlet-mapping>

<servlet>
    <servlet-name>spring</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>2</load-on-startup>
</servlet>


spring-servlet.xml

<bean id="methodNameResolver"
        class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver">
    <property name="paramName">
        <value>method</value>
    </property>
    <property name="defaultMethodName">
        <value>form</value>
    </property>
</bean>

<bean id="actionBean" abstract="true">
    <property name="methodNameResolver" ref="methodNameResolver" />
</bean>

<bean name="/test/test1.do" parent="actionBean"  class="com.freeend.web.test.TestController">  
</bean>


 역시나 아무리 생각해봐도 문제는 없다. 역시 난 빈틈 없음. 틀리지 않아.
 그럼 뭐가 문제인가!!
 역시 구글신께 물어봤다. 네이버 버려. 구굴이 甲이여.

 역시. 조선人 보단 양키가 낫다. ㅋㅋ 

Nick's Blog (http://tcob.com/c/tech)

That’s a terrible blog post title, I know. Nevertheless, I just burned 90 minutes trying to figure out why a simple Spring MultiActionController setup left me with an error: “No request handling method with name ‘list’ in class.” Google was little help, so I resorted to Bing.

Eventually, I found a buried forum response with my exact problem, I had referenced the wrong package’s type! If you’re running in to this, make sure you do this:

import org.springframework.web.servlet.ModelAndView;

and not this:

import org.springframework.web.portlet.ModelAndView;

This will teach me to be more mindful of what Eclipse decides to add for me automatically


란다. 오호홋 감사.

 문제는 ModelAndView의 import가 잘못되어 Resolver가 파라메터로 받은 값과 똑같은 메소드를 찾지 못한거다. 왜냐!! 리턴값이 다르기 때문이지.

 
해결

이런. 어쨌든. 이 문제의 잘못은 이클립스의 자동완성기능에 있었다. 누구나 코딩을 할때.. 아래와 같이 할껄.


저러고 걍 엔터 누르겠지.
 마지막에 port... 뭐시기인지 그 밑에 serv... 뭐시기인지 확인도 않하고 걍 엔터 눌렀겠지...
이게 문제였다. 이 바부. 이런 바보가 양키도 있다. ㅋㅋㅋ 조선人만의 문제가 아니라 글로벌적인 문제였던 것이다.

어쨌든 이클립스가 지멋대로 

import org.springframework.web.portlet.ModelAndView;

이렇게 추천해줘서 내가 선택한 import를 

import org.springframework.web.servtle.ModelAndView;
이렇게 수정해서 해결하였다.

 아. 고마워 양키. 너의 올해 3월의 실수가 날 도왔어. ^___________^. 이상 지영옹.
반응형