- 특정 파라미터의 값이나 URL 등을 이용해여 해당 클래스의 메소드를 실행시킴.
- 비슷한 기능을 가진 메서드를 모아 불필요한 클래스를 많이 생성하는 것을 줄여줌
public [ModelAndView | Map | void] methodName(HttpServletRequest request, HttpServletResponse response) public [ModelAndView | Map | void] methodName(HttpServletRequest request, HttpServletResponse response, SomeCommand command) |
- return 값은 ModelAndView, Map, void 중의 하나여야 함
- 반드시 첫번째 파라미터의 경우는 HttpServletRequest, 두번째 파라미터의 경우는 HttpServletResponse이며, 세번째는 선택적으로 지정할 수 있음.
● MethodNameResolver 종류
◑ ParameterMethodNameResolver : 특정 파라미터의 값을 메서드 이름으로 사용
◑ InternalPathMethodNameResolver(default) : URL의 마지막 경로를 메서드 이름으로 사용
◑ PropertiesMethodNameResolver : URL과 메서드 이름의 매핑을 프로퍼티로 설정
package controller; import javax.servlet.http.HttpServletRequest; public class BoardMultiActionController extends MultiActionController { public ModelAndView onBoardList(HttpServletRequest request, HttpServletResponse response){ |
◑ ParameterMethodNameResolver : 특정 파라미터의 값을 메서드 이름으로 사용
<?xml version="1.0" encoding="UTF-8"?>
|
log 출력 //http://localhost:8080/springMVC//multi.sp?mode=onBoardList <<<<< onBoardList >>>>> type = null //http://localhost:8080/springMVC//multi.sp?mode=onBoardDetail&type=003 <<<<< onBoardDetail >>>>> type = 003 |
◑ InternalPathMethodNameResolver : URL의 마지막 경로를 메서드 이름으로 사용 - 가장 많이쓰는 형태
<?xml version="1.0" encoding="UTF-8"?>
|
log 출력 //http://localhost:8080/springMVC/onBoardList.sp <<<<< onBoardList >>>>> type = null //http://localhost:8080/springMVC/onBoardDetail.sp?type=007 <<<<< onBoardDetail >>>>> type = 007 |
◑ PropertiesMethodNameResolver : URL과 메서드 이름의 매핑을 프로퍼티로 설정
<?xml version="1.0" encoding="UTF-8"?>
|
log 출력 //http://localhost:8080/springMVC/boardList.sp <<<<< onBoardList >>>>> type = null //http://localhost:8080/springMVC/boardInsert.sp?type=123 <<<<< onBoardInsert >>>>> type = 123 |
'프로그램 > Spring 2.5' 카테고리의 다른 글
AOP 구현 (0) | 2012.03.19 |
---|---|
AOP(Aspect Oriented Programming) - 관점 지향 프로그래밍 (0) | 2012.03.19 |
SimpleFormController (0) | 2012.03.10 |
AbstractCommandController (0) | 2012.03.08 |
AbstractController (0) | 2012.03.07 |