<html>
<head>
<%if(request.getAttribute("msg")!=null){%>
<script>
alert("<%=request.getAttribute("msg")%>");
</script>
<%}%>
</head>
<body>
<html:form action="/test.shtml?action=list" method="post">
<table>
<input name ="submit1" type="button" value="查询" οnclick="clickBtn(1)"/>
<input name ="submit2" type="button" value="添加" οnclick="clickBtn(2)"/>
<input name ="submit3" type="button" value="删除" οnclick="clickBtn(3)"/>
</table>
<table>
<tr>
<td align="center" valign="middle" bgcolor="#DDEEF8" nowrap class="tb27">编号</td>
<td align="center" valign="middle" bgcolor="#DDEEF8" nowrap class="tb29">名称</td>
</tr>
<tr>
<logic:notEmpty name="rs" >
<logic:iterate name="rs" id="itm">
<td align="center" valign="middle" class="tb27"> <bean:write name="itm" property="userno"/></td>
<td align="center" valign="middle" class="tb29"> <bean:write name="itm" property="username"/></td>
</logic:iterate>
</logic:notEmpty>
</tr>
</table>
</html:form>
</body>
<html>
<script language="javascript">
function clickBtn(no){
if(no==1){
document.forms[0].action="/test/test.shtml?action=list";
}else if (no==2){
document.forms[0].action="/test/test.shtml?action=add";
}else if (no==3){
document.forms[0].action="/test/test.shtml?action=del";
}
document.forms[0].submit();
}
</script>
=========================Action=========================
public class TestAction extends DispatchAction {
public ActionForward add(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response){
String msg="";
TestDao dao=new TestDao();
if(dao.add()==true){
msg="添加成功!"; //这个传到页面用
}else{
msg="添加失败";
}
request.setAttribute("msg",msg);
return mapping.findForward("list");
}
}
=====================struts-config.xml==================
<action-mapping>
<action name="testForm" path="/test" scope="request"
parameter="action" type="******.action.TestAction">
<forward name="index" path="/index.jsp">
<forward name="list" path="/test.shmt?action=list"/> //注意这个地方 可以进行跳转(页面的功能相同)
</action-mapping>