浏览 2379 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2010-01-12
最后修改:2010-09-14
jsp: <body> <html:form action="/my"> age : <html:text property="age"/><html:errors property="age"/><br/> name : <html:text property="name"/><html:errors property="name"/><br/> <input type="submit" name="method" value="save"/> <input type="submit" name="method" value="delete"/> <input type="submit" name="method" value="search"/> </html:form> </body> action: public class MyAction extends LookupDispatchAction { ... public ActionForward saveAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { MyForm myForm = (MyForm) form;// TODO Auto-generated method stub System.out.println("MyAction...save(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)"); return mapping.findForward("succ"); } public ActionForward deleteAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { MyForm myForm = (MyForm) form;// TODO Auto-generated method stub System.out.println("MyAction...delete(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)"); return mapping.findForward("succ"); } public ActionForward searchAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { MyForm myForm = (MyForm) form;// TODO Auto-generated method stub System.out.println("MyAction...search(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)"); return mapping.findForward("succ"); } /** * 必须覆盖 */ protected Map getKeyMethodMap() { // TODO Auto-generated method stub /** * key对应ApplicationResources.properties中=前面 * value对应action中的方法名 * * ApplicationResources.properties中=后面对应jsp按钮value */ Map<String, String> m = new HashMap<String, String>(); m.put("button.save", "saveAction"); m.put("button.delete", "deleteAction"); m.put("button.search", "searchAction"); return m; } Struts-config.xml 记得加上 parameter="method" ApplicationResources.properties: button.save=save button.delete=delete button.search=search 有一点可以看到,地址栏里面没有显示方法名../../my.do隐藏掉了,呵。 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2010-05-07
写的还不错,嘻嘻~
|
|
返回顶楼 | |
发表时间:2010-05-26
这个是不是对中文有限制啊
|
|
返回顶楼 | |