Wildcard ActionMappingsって役に立つなー

Ajax.Requestを利用して入力パラメータチェックをするなら、Wildcard ActionMappingsが使えそうだなーと思ったので、Actionまわりを修正。
まずは、必ず"success"を返すActionを作る。

public class SuccessActionCommon extends Action {

	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		return mapping.findForward("success");

	}

}

Actionクラス名が変なのは気にしない。POJOのActionにしなかった理由は、、、なんとなくだけど、、、少しは理由があるかも。相性かな。。。POJOのActionでもいいと思うけど。今はこれで行くことにする。
そしてstruts-config.xmlにaction-mappingを追加する

    <action-mappings>
        <action
            path="/*Validator"
            type="examples.commons.action.SuccessActionCommon"
            name="{1}"
            scope="request"
            validate="true"
            input="/pages/inputError.jsp">
            <forward
                name="success"
                path="/pages/inputSuccess.jsp"/>

        </action> 
    </action-mappings>

こんな感じで。
あとJSPのhtml:formタグを

<html:form action="/storeFormValidator" method="POST">

のように修正して、Tomcat起動。



きちんと動いた!!
初めてWildcard ActionMappingsを使ったけど便利だなー。