ParameterMethodNameResolver는 parameter에 설정된 method를 request 를 처리할 method 를 결정한다.
ex> action.do?method=update 요청이 들어오면 method(HttpServletRequest , HttpServletResponse) 메소드를 호출한다.
With ParameterMethodNameResolver configured, and define the parameter name thought the “paramName” property:
<beans ...> <bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping" /> <bean class="com.mkyong.common.controller.CustomerController"> <property name="methodNameResolver"> <bean class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver"> <property name="paramName" value="action"/> </bean> </property> </bean> </beans>
Now, the URL will map to the method name via the “action” request parameter name :
- /customer/*.htm?action=add –> add() method
- /customer/whatever.htm?action=add –> add() method
- /customer/*.htm?action=update –> update() method
- /customer/*.htm?action=delete –> delete() method
- /customer/*.htm?action=list –> list() method
'Programming > Spring' 카테고리의 다른 글
객체 검증의 종결자 @Valid (0) | 2014.08.27 |
---|---|
@ModelAttribute와 @SessionAttributes의 이해와 한계 (0) | 2014.08.27 |
Spring MVC 와 DispatcherServlet (0) | 2014.07.01 |
InternalResourceViewResolver (0) | 2014.07.01 |
[Spring] sitemesh 설정하기 (0) | 2014.03.12 |