このStruts ForwardActionの例をダウンロードする –

Struts-ForwardAction-Example.zip

StrutsのMVCモデルでは、新しいViewページを取得するためにAction Controllerを考える必要があります。場合によっては、指定されたJSPページのみを取得する必要があります。たとえば、ページを転送するアクションコントローラクラスを作成するのは馬鹿です

public ActionForward execute(ActionMapping mapping,ActionForm form,
    HttpServletRequest request,HttpServletResponse response)
        throws Exception {

    return mapping.findForward("success");
}

   <action path="/Welcome"
    type="com.mkyong.common.action.WelcomeAction">
    <forward name="success" path="/Welcome.jsp"/>
   </action>

Strutsには

ForwardAction

(org.apache.struts.actions.ForwardAction)という特別なアクション・コントローラ・クラスが付属しており、記述された名前で「

forward-only

」タスクを実行し、指定されたJSPページに直接アクセスできるようにします。




/Welcome

” Webパスを宣言し、

ForwardAction

クラスとして属性を入力し、

Welcome.jsp

ページに転送します。


struts-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://jakarta.apache.org/struts/dtds/struts-config__1__3.dtd">

<struts-config>

    <action-mappings>

        <action
            path="/Welcome"
            type="org.apache.struts.actions.ForwardAction"
            parameter="/pages/Welcome.jsp"/>

    </action-mappings>

</struts-config>


Welcome.jsp

This is Welcome Page

ForwardAction Example


struts-forwardaction-example1、title = "struts-forwardaction-example1"


struts-forwardaction-example2、title = "struts-forwardaction-example2"