An abstract Action that dispatches to the subclass mapped <action path="/test" type="org.example.MyAction" name="MyForm" scope="request" input="/test.jsp" parameter="method"/> which will use the value of the request parameter named "method" to locate the corresponding key in ApplicationResources. For example, you might have the following ApplicationResources.properties: button.add=Add Record button.delete=Delete Record And your JSP would have the following format for submit buttons: <html:form action="/test"> <html:submit property="method"> <bean:message key="button.add"/> </html:submit> <html:submit property="method"> <bean:message key="button.delete"/> </html:submit> </html:form> Your subclass must implement both getKeyMethodMap and the methods defined in the map. An example of such implementations are: protected Map getKeyMethodMap() { Map map = new HashMap(); map.put("button.add", "add"); map.put("button.delete", "delete"); return map; } public ActionForward add(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // do add return mapping.findForward("success"); } public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // do delete return mapping.findForward("success"); } Notes - If duplicate values exist for the keys returned by getKeys, only the first one found will be returned. If no corresponding key is found then an exception will be thrown. You can override the method
|
LookupDispatchAction使用示例
最新推荐文章于 2017-11-26 11:43:00 发布
LookupDispatchAction