Action:
   public ActionForward execute
(
ActionForm form,ActionMapping mapping,
HttpServletRequest request,HttpServletResponse response
)throws IOException,ServletException
{
InsertForm insertForm = (InsertForm)form;
String name = insertForm.getName();
String phone = insertForm.getPhone();
String address = insertForm.getAddress();
ActionMessages errors = new ActionMessages();
DataSource dataSource;
Connection conn = null;
try
{
dataSource = getDataSource(request,"A");
conn = dataSource.getConnection();
AddressBookBo abbo = new AddressBookBo(name,phone,address);
abbo.insert();
}catch(Exception ex)
{
ex.printStackTrace();
errors.add(ActionMessages.GLOBAL_MESSAGE,new ActionMessage("error.insert.failed"));
}
if(!errors.isEmpty())
{
saveErrors(request,errors);
return (new ActionForward(mapping.getInput()));
}
ActionMessages actionMessages = new ActionMessages();
actionMessages.add(ActionMessages.GLOBAL_MESSAGE,new ActionMessage("record.insert"));
saveMessages(request,actionMessages);
return (mapping.findForward("confirmation"));
}
action-mapping配置:
...
<global-forwards>
    <forward   name="confirmation"    path="/pages/confirmation.jsp"/>    
    </global-forwards>
...
 <action
     input="/pages/insert.jsp"
     type="action.InsertAction"
     name="insertForm"
     scope="request"
     validate="true"
     path="/insertAction">
    </action>
...