struts-config.xml에서의 설정으로는 동적으로 바뀌는 파라메터를 넘겨줄 수 없다.

그래서, 액션 클래스에서의 특별한 처리를 요구하는 데, 다음중 한 방법을 사용하면 된다.


  1.  ActionFoward 객체 직접 생성

    다음과 같이 ActionForward객체를 생성하여 리턴한다.
    return new ActionForward("/index.html?param=" + paramValue, true);

    파라메터가 많을 경우 코드가 지저분해지고 번거러울 수 있다.


  2. ActionMapping객체를 통한 ActionFoward객체 생성

    대부분의 경우 이같은 방법으로 포워드시킨다.

    excute() 메소드에서 전달 받은 ActionMapping 객체를 이용한다.
    ActionForward forward = mapping.findForward("success");
    ActionForward redirect

    = new ActionForward(forward.getName(), forward.getPath()
    + "?param=" + paramValue, true );

    return redirect;


  3. ActionRedirect 클래스 활용

    org.apache.struts.action.ActionRedirect 클래스를 import시켜서 사용한다.
    ActionRedirect redirect = new ActionRedirect( mapping.findForward("success") );
      redirect.addParameter("param", paramValue);
    return redirect;
    * 주의 : 이 방법은 struts 1.2.7 버전 부터 가능하다.



이 글은 스프링노트에서 작성되었습니다.

작업노트/Framework l 2008. 1. 14. 16:07

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

카테고리

분류 전체보기 (117)
작업노트 (98)
거미줄세상 (12)
쌓기 (1)
책읽기 (0)
Reviews (4)

달력

«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
get rsstistory! Tistory Tistory 가입하기!