- 浏览: 1524961 次
- 性别:
- 来自: 杭州
文章分类
- 全部博客 (525)
- SEO (16)
- JAVA-EE-Hibernate (6)
- JAVA-EE-Struts (29)
- JAVA-EE-Spring (15)
- Linux (37)
- JAVA-SE (29)
- NetWork (1)
- CMS (14)
- Semantic Research (3)
- RIA-Flex (0)
- Ajax-Extjs (4)
- Ajax-Jquery (1)
- www.godaddy.com (0)
- SSH (34)
- JavaScript (6)
- SoftwareEngineer (9)
- CMMI (0)
- IDE-Myeclipse (3)
- PHP (1)
- Algorithm (3)
- C/C++ (18)
- Concept&Items (2)
- Useful WebSite (1)
- ApacheServer (2)
- CodeReading (1)
- Socket (2)
- UML (10)
- PowerDesigner (1)
- Repository (19)
- MySQL (3)
- SqlServer (0)
- Society (1)
- Tomcat (7)
- WebService (5)
- JBoss (1)
- FCKeditor (1)
- PS/DW/CD/FW (0)
- DesignPattern (11)
- WebSite_Security (1)
- WordPress (5)
- WebConstruction (3)
- XML|XSD (7)
- Android (0)
- Project-In-Action (9)
- DatabaseDesign (3)
- taglib (7)
- DIV+CSS (10)
- Silverlight (52)
- JSON (7)
- VC++ (8)
- C# (8)
- LINQ (1)
- WCF&SOA (5)
- .NET (20)
- SOA (1)
- Mashup (2)
- RegEx (6)
- Psychology (5)
- Stock (1)
- Google (2)
- Interview (4)
- HTML5 (1)
- Marketing (4)
- Vaadin (2)
- Agile (2)
- Apache-common (6)
- ANTLR (0)
- REST (1)
- HtmlAnalysis (18)
- csv-export (3)
- Nucth (3)
- Xpath (1)
- Velocity (6)
- ASP.NET (9)
- Product (2)
- CSS (1)
最新评论
-
lt26w:
理解成门面模式应该比较容易明白吧
FacadePattern-Java代码实例讲解 -
lt26w:
看下面的例子比较明白.
FacadePattern-Java代码实例讲解 -
javaloverkehui:
这也叫文档,别逗我行吗,也就自己看看。
HtmlCleaner API -
SE_XiaoFeng:
至少也应该写个注释吧。
HtmlCleaner API -
jfzshandong:
...
org.springframework.web.filter.CharacterEncodingFilter 配置
一个Action对应多个Form
关键字: action form
Action:
Java代码 <embed type="application/x-shockwave-flash" width="14" height="15" src="http://awp.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" flashvars="clipboard=package%20com.awp.test.action%3B%0A%0Aimport%20javax.servlet.http.HttpServletRequest%3B%0Aimport%20javax.servlet.http.HttpServletResponse%3B%0A%0Aimport%20org.apache.struts.action.ActionForm%3B%0Aimport%20org.apache.struts.action.ActionForward%3B%0Aimport%20org.apache.struts.action.ActionMapping%3B%0Aimport%20org.apache.struts.actions.DispatchAction%3B%0A%0Aimport%20com.awp.test.form.FirstForm%3B%0Aimport%20com.awp.test.form.SecondForm%3B%0A%0A%2F**%0A%20*%20%40version%201.0%0A%20*%20%40author%20awp%0A%20*%20%40date%202009-4-24%20%E4%B8%8A%E5%8D%8811%3A25%3A49%0A%20*%20%40decription%20%E4%B8%80%E4%B8%AAAction%E4%B8%AD%E5%8C%85%E5%90%AB%E5%A4%9A%E4%B8%AAForm%20%0A%20*%2F%0Apublic%20class%20MultiFormTestAction%20extends%20DispatchAction%20%7B%0A%0A%09%2F**%0A%09%20*%20%E7%AC%AC%E4%B8%80%E4%B8%AAForm%E5%AF%B9%E5%BA%94%E6%96%B9%E6%B3%95%0A%09%20*%2F%20%0A%09public%20ActionForward%20firstForm(ActionMapping%20mapping%2C%20ActionForm%20form%2C%0A%09%09%09HttpServletRequest%20request%2C%20HttpServletResponse%20response)%7B%0A%09%09%09FirstForm%09beanform%09%3D%09(FirstForm)form%3B%0A%09%09%09request.setAttribute(%22name%22%2C%20beanform.getName())%3B%0A%09%09%09return%20mapping.findForward(%22display%22)%3B%0A%09%7D%0A%09%2F**%0A%09%20*%20%20%E7%AC%AC%E4%BA%8C%E4%B8%AAForm%E5%AF%B9%E5%BA%94%E6%96%B9%E6%B3%95%0A%09%20*%2F%20%0A%09public%20ActionForward%20secondForm(ActionMapping%20mapping%2C%20ActionForm%20form%2C%0A%09%09%09HttpServletRequest%20request%2C%20HttpServletResponse%20response)%7B%0A%09%09%09SecondForm%09beanform%09%3D%09(SecondForm)form%3B%0A%09%09%09request.setAttribute(%22name%22%2C%20beanform.getName())%3B%0A%09%09%09return%20mapping.findForward(%22display%22)%3B%0A%09%7D%0A%7D%0A" quality="high" allowscriptaccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
- package com.awp.test.action;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import org.apache.struts.action.ActionForm;
- import org.apache.struts.action.ActionForward;
- import org.apache.struts.action.ActionMapping;
- import org.apache.struts.actions.DispatchAction;
- import com.awp.test.form.FirstForm;
- import com.awp.test.form.SecondForm;
- /**
- * @version 1.0
- * @author awp
- * @date 2009-4-24 上午11:25:49
- * @decription 一个Action中包含多个Form
- */
- public class MultiFormTestAction extends DispatchAction {
- /**
- * 第一个Form对应方法
- */
- public ActionForward firstForm(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response){
- FirstForm beanform = (FirstForm)form;
- request.setAttribute("name" , beanform.getName());
- return mapping.findForward( "display" );
- }
- /**
- * 第二个Form对应方法
- */
- public ActionForward secondForm(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response){
- SecondForm beanform = (SecondForm)form;
- request.setAttribute("name" , beanform.getName());
- return mapping.findForward( "display" );
- }
- }
package com.awp.test.action; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.actions.DispatchAction; import com.awp.test.form.FirstForm; import com.awp.test.form.SecondForm; /** * @version 1.0 * @author awp * @date 2009-4-24 上午11:25:49 * @decription 一个Action中包含多个Form */ public class MultiFormTestAction extends DispatchAction { /** * 第一个Form对应方法 */ public ActionForward firstForm(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){ FirstForm beanform = (FirstForm)form; request.setAttribute("name", beanform.getName()); return mapping.findForward("display"); } /** * 第二个Form对应方法 */ public ActionForward secondForm(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){ SecondForm beanform = (SecondForm)form; request.setAttribute("name", beanform.getName()); return mapping.findForward("display"); } }
Form:
Java代码 <embed type="application/x-shockwave-flash" width="14" height="15" src="http://awp.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" flashvars="clipboard=package%20com.awp.test.form%3B%0A%0Aimport%20org.apache.struts.action.ActionForm%3B%0A%0Apublic%20class%20FirstForm%20extends%20ActionForm%20%7B%0A%0A%09private%20String%09name%3B%0A%0A%09public%20String%20getName()%20%7B%0A%09%09return%20name%3B%0A%09%7D%0A%0A%09public%20void%20setName(String%20name)%20%7B%0A%09%09this.name%20%3D%20name%3B%0A%09%7D%0A%0A%7D" quality="high" allowscriptaccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
- package com.awp.test.form;
- import org.apache.struts.action.ActionForm;
- public class FirstForm extends ActionForm {
- private String name;
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this .name = name;
- }
- }
package com.awp.test.form; import org.apache.struts.action.ActionForm; public class FirstForm extends ActionForm { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } }
Java代码 <embed type="application/x-shockwave-flash" width="14" height="15" src="http://awp.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" flashvars="clipboard=package%20com.awp.test.form%3B%0A%0Aimport%20org.apache.struts.action.ActionForm%3B%0A%0Apublic%20class%20SecondForm%20extends%20ActionForm%20%7B%0A%0A%09private%20String%09name%3B%0A%0A%09public%20String%20getName()%20%7B%0A%09%09return%20name%3B%0A%09%7D%0A%0A%09public%20void%20setName(String%20name)%20%7B%0A%09%09this.name%20%3D%20name%3B%0A%09%7D%0A%0A%7D" quality="high" allowscriptaccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
- package com.awp.test.form;
- import org.apache.struts.action.ActionForm;
- public class SecondForm extends ActionForm {
- private String name;
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this .name = name;
- }
- }
package com.awp.test.form; import org.apache.struts.action.ActionForm; public class SecondForm extends ActionForm { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } }
struts-cofing.xml
Xml代码 <embed type="application/x-shockwave-flash" width="14" height="15" src="http://awp.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" flashvars="clipboard=%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%3F%3E%0A%3C!DOCTYPE%20struts-config%20PUBLIC%20%22-%2F%2FApache%20Software%20Foundation%2F%2FDTD%20Struts%20Configuration%201.1%2F%2FEN%22%20%0A%22http%3A%2F%2Fjakarta.apache.org%2Fstruts%2Fdtds%2Fstruts-config_1_1.dtd%22%3E%0A%3Cstruts-config%3E%0A%09%3Cform-beans%3E%0A%09%09%3Cform-bean%20name%3D%22firstform%22%20type%3D%22com.awp.test.form.FirstForm%22%2F%3E%0A%09%09%3Cform-bean%20name%3D%22secondform%22%20type%3D%22com.awp.test.form.SecondForm%22%2F%3E%0A%09%3C%2Fform-beans%3E%0A%09%3Cglobal-forwards%3E%0A%09%09%3Cforward%20name%3D%22display%22%20path%3D%22%2Fdisplay.jsp%22%2F%3E%0A%09%3C%2Fglobal-forwards%3E%0A%09%3Caction-mappings%3E%0A%09%09%3Caction%20path%3D%22%2Ffirstpath%22%0A%09%09%09%09input%3D%22%2Ffirst.jsp%22%0A%09%09%09%09name%3D%22firstform%22%0A%09%09%09%09parameter%3D%22method%22%0A%09%09%09%09scope%3D%22request%22%0A%09%09%09%09type%3D%22com.awp.test.action.MultiFormTestAction%22%2F%3E%0A%09%09%09%09%0A%09%09%3Caction%20path%3D%22%2Fsecondpath%22%0A%09%09%09%09input%3D%22%2Fsecond.jsp%22%0A%09%09%09%09name%3D%22secondform%22%0A%09%09%09%09parameter%3D%22method%22%0A%09%09%09%09scope%3D%22request%22%0A%09%09%09%09type%3D%22com.awp.test.action.MultiFormTestAction%22%2F%3E%09%09%09%09%0A%09%3C%2Faction-mappings%3E%0A%09%3Cmessage-resources%20parameter%3D%22MessageResources%22%20%2F%3E%20%0A%3C%2Fstruts-config%3E%0A%0A" quality="high" allowscriptaccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
- <? xml version = "1.0" encoding = "UTF-8" ?>
- <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
- "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd " >
- < struts-config >
- < form-beans >
- < form-bean name = "firstform" type = "com.awp.test.form.FirstForm" />
- < form-bean name = "secondform" type = "com.awp.test.form.SecondForm" />
- </ form-beans >
- < global-forwards >
- < forward name = "display" path = "/display.jsp" />
- </ global-forwards >
- < action-mappings >
- < action path = "/firstpath"
- input = "/first.jsp"
- name = "firstform"
- parameter = "method"
- scope = "request"
- type = "com.awp.test.action.MultiFormTestAction" />
- < action path = "/secondpath"
- input = "/second.jsp"
- name = "secondform"
- parameter = "method"
- scope = "request"
- type = "com.awp.test.action.MultiFormTestAction" />
- </ action-mappings >
- < message-resources parameter = "MessageResources" />
- </ struts-config >
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"> <struts-config> <form-beans> <form-bean name="firstform" type="com.awp.test.form.FirstForm"/> <form-bean name="secondform" type="com.awp.test.form.SecondForm"/> </form-beans> <global-forwards> <forward name="display" path="/display.jsp"/> </global-forwards> <action-mappings> <action path="/firstpath" input="/first.jsp" name="firstform" parameter="method" scope="request" type="com.awp.test.action.MultiFormTestAction"/> <action path="/secondpath" input="/second.jsp" name="secondform" parameter="method" scope="request" type="com.awp.test.action.MultiFormTestAction"/> </action-mappings> <message-resources parameter="MessageResources" /> </struts-config>
first.jsp
Html代码 <embed type="application/x-shockwave-flash" width="14" height="15" src="http://awp.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" flashvars="clipboard=%3C%25%40%20page%20language%3D%22java%22%20pageEncoding%3D%22UTF-8%22%25%3E%0A%3C!doctype%20html%20public%20%22-%2F%2FW3C%2F%2FDTD%20XHTML%201.0%20Transitional%2F%2FEN%22%20%0A%22http%3A%2F%2Fwww.w3.org%2FTR%2Fxhtml1%2FDTD%2Fxhtml1-transitional.dtd%22%3E%0A%3Chtml%3E%0A%20%20%3Chead%3E%0A%20%20%20%20%3Ctitle%3E%E6%88%91%E6%98%AF%E6%8F%90%E4%BA%A4%E7%AC%AC%E4%B8%80%E4%B8%AAFORM%E7%9A%84%E9%A1%B5%E9%9D%A2%3C%2Ftitle%3E%0A%20%20%3C%2Fhead%3E%0A%20%20%3Cbody%3E%0A%20%20%20%3Cform%20action%3D%22%3C%25%3Drequest.getContextPath()%25%3E%2Ffirstpath.do%3Fmethod%3DfirstForm%22%20method%3D%22post%22%3E%0A%20%20%20%09%3Cinput%20name%3D%22name%22%20value%3D%22%22%20type%3D%22text%22%2F%3E%0A%20%20%20%09%3Cinput%20name%3D%22ok%22%20value%3D%22%E6%8F%90%E4%BA%A4%22%20type%3D%22submit%22%2F%3E%0A%20%20%20%3C%2Fform%3E%0A%20%20%3C%2Fbody%3E%0A%3C%2Fhtml%3E%0A" quality="high" allowscriptaccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
- < %@ page language = "java" pageEncoding = "UTF-8" % >
- <!doctype html public "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " >
- < html >
- < head >
- < title > 我是提交第一个FORM的页面 </ title >
- </ head >
- < body >
- < form action = "<%=request.getContextPath()%>/firstpath.do?method=firstForm" method = "post" >
- < input name = "name" value = "" type = "text" />
- < input name = "ok" value = "提交" type = "submit" />
- </ form >
- </ body >
- </ html >
<%@ page language="java" pageEncoding="UTF-8"%> <!doctype html public "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>我是提交第一个FORM的页面</title> </head> <body> <form action="<%=request.getContextPath()%>/firstpath.do?method=firstForm" method="post"> <input name="name" value="" type="text"/> <input name="ok" value="提交" type="submit"/> </form> </body> </html>
second.jsp
Html代码 <embed type="application/x-shockwave-flash" width="14" height="15" src="http://awp.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" flashvars="clipboard=%3C%25%40%20page%20language%3D%22java%22%20pageEncoding%3D%22UTF-8%22%25%3E%0A%3C!doctype%20html%20public%20%22-%2F%2FW3C%2F%2FDTD%20XHTML%201.0%20Transitional%2F%2FEN%22%20%0A%22http%3A%2F%2Fwww.w3.org%2FTR%2Fxhtml1%2FDTD%2Fxhtml1-transitional.dtd%22%3E%0A%3Chtml%3E%0A%20%20%3Chead%3E%0A%20%20%20%20%3Ctitle%3E%E6%88%91%E6%98%AF%E6%8F%90%E4%BA%A4%E7%AC%AC%E4%BA%8C%E4%B8%AAFORM%E7%9A%84%E9%A1%B5%E9%9D%A2%3C%2Ftitle%3E%0A%20%20%3C%2Fhead%3E%0A%20%20%3Cbody%3E%0A%20%20%20%3Cform%20action%3D%22%3C%25%3Drequest.getContextPath()%25%3E%2Fsecondpath.do%3Fmethod%3DsecondForm%22%20method%3D%22post%22%3E%0A%20%20%20%09%3Cinput%20name%3D%22name%22%20value%3D%22%22%20type%3D%22text%22%2F%3E%0A%20%20%20%09%3Cinput%20name%3D%22ok%22%20value%3D%22%E6%8F%90%E4%BA%A4%22%20type%3D%22submit%22%2F%3E%0A%20%20%20%3C%2Fform%3E%0A%20%20%3C%2Fbody%3E%0A%3C%2Fhtml%3E" quality="high" allowscriptaccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
- < %@ page language = "java" pageEncoding = "UTF-8" % >
- <!doctype html public "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " >
- < html >
- < head >
- < title > 我是提交第二个FORM的页面 </ title >
- </ head >
- < body >
- < form action = "<%=request.getContextPath()%>/secondpath.do?method=secondForm" method = "post" >
- < input name = "name" value = "" type = "text" />
- < input name = "ok" value = "提交" type = "submit" />
- </ form >
- </ body >
- </ html >
<%@ page language="java" pageEncoding="UTF-8"%> <!doctype html public "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>我是提交第二个FORM的页面</title> </head> <body> <form action="<%=request.getContextPath()%>/secondpath.do?method=secondForm" method="post"> <input name="name" value="" type="text"/> <input name="ok" value="提交" type="submit"/> </form> </body> </html>
display.jsp
Html代码 <embed type="application/x-shockwave-flash" width="14" height="15" src="http://awp.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" flashvars="clipboard=%3C%25%40%20page%20language%3D%22java%22%20pageEncoding%3D%22UTF-8%22%25%3E%0A%3C!doctype%20html%20public%20%22-%2F%2FW3C%2F%2FDTD%20XHTML%201.0%20Transitional%2F%2FEN%22%20%0A%22http%3A%2F%2Fwww.w3.org%2FTR%2Fxhtml1%2FDTD%2Fxhtml1-transitional.dtd%22%3E%0A%3Chtml%3E%0A%20%20%3Chead%3E%0A%20%20%20%20%3Ctitle%3E%E6%98%BE%E7%A4%BA%E9%A1%B5%E9%9D%A2%3C%2Ftitle%3E%0A%20%20%3C%2Fhead%3E%0A%20%20%3Cbody%3E%0A%20%20%3Cbr%20%2F%3E%0A%20%20%20%E8%A1%A8%E5%8D%95%E6%8F%90%E4%BA%A4%E7%9A%84%E5%86%85%E5%AE%B9%E4%B8%BA%EF%BC%9A%24%7Bname%7D%20%3Cbr%20%2F%3E%3Cbr%20%2F%3E%0A%20%20%20%3Ca%20href%3D%22first.jsp%22%3E%E6%89%93%E5%BC%80%E8%A1%A8%E5%8D%951%3C%2Fa%3E%3Cbr%20%2F%3E%3Cbr%20%2F%3E%0A%20%20%20%3Ca%20href%3D%22second.jsp%22%3E%E6%89%93%E5%BC%80%E8%A1%A8%E5%8D%952%3C%2Fa%3E%0A%20%20%3C%2Fbody%3E%0A%3C%2Fhtml%3E%0A" quality="high" allowscriptaccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
- < %@ page language = "java" pageEncoding = "UTF-8" % >
- <!doctype html public "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " >
- < html >
- < head >
- < title > 显示页面 </ title >
- </ head >
- < body >
- < br />
- 表单提交的内容为:${name} < br /> < br />
- < a href = "first.jsp" > 打开表单1 </ a > < br /> < br />
- < a href = "second.jsp" > 打开表单2 </ a >
- </ body >
- </ html >
<%@ page language="java" pageEncoding="UTF-8"%> <!doctype html public "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>显示页面</title> </head> <body> <br /> 表单提交的内容为:${name} <br /><br /> <a href="first.jsp">打开表单1</a><br /><br /> <a href="second.jsp">打开表单2</a> </body> </html>
Action必须继承DispatchAction,感觉其实一个action还是只能对应一个form
这里的方法其实是利用action的path 多个path可以指向同一个action。
发表评论
-
fckedit和struts2集成不能上传文件的解决方法
2010-01-24 10:52 1613以前在使用fckedit+strut1上传文件很顺利,后来使用 ... -
struts validator框架
2010-01-09 13:56 1425Struts 验证器基础 步骤 1. 安装 Strut ... -
The path of an ForwardConfig cannot be null-struts validator验证框架异常
2010-01-09 13:54 3045struts validator验证框架异常 在测 ... -
关于一个Action对应多个Form
2009-12-28 23:49 1504由于一个Action可以用多个path来访问,所以我们可以通过 ... -
DynaValidatorForm类
2009-12-28 23:23 1284DynaValidatorForm类 http ... -
Struts出现No getter method for property的解决
2009-12-28 22:48 2006请从一下几方面着手检查代码 1、JavaBean中的属性 ... -
Struts Validator验证器使用指南
2009-12-07 18:34 785Struts Validator 验证器 ... -
Form '***' not found for locale 'zh _CN'
2009-12-07 16:13 4360Form '***' not found for locale ... -
Struts2 拦截器详细配置过程
2009-12-06 21:23 18181:所有拦截器的超级接口Interceptor ,Ac ... -
如何在SSH框架中使用Validator框架
2009-12-05 00:19 1330关键字: validator 下 ... -
java.lang.NoSuchMethodException
2009-12-04 23:56 2046关键字: validator 下面将介绍如何在SSH框架 ... -
Struts验证框架与一些技巧
2009-12-04 23:46 16171还是通过一些步骤例子说明 首先建立Struts工程的时候要 ... -
Struts-validator验证框架与一些技巧
2009-12-04 23:44 1156这个框架褒贬不一呀~~~ =========== ... -
struts 标签详解
2009-12-04 21:28 1032struts 标签详解 Action和jsp的开发其实就 ... -
HTTP Status 404 - Servlet action is not available(二)
2009-12-04 18:41 5870今天在帮公司的新手弄SSH的一个登录程序时,出现了Servle ... -
HTTP Status 404 - Servlet action is not available(一)
2009-12-04 18:40 7828sp /meCall 发表于2007-10-08, 1 ... -
SSH中Cannot retrieve mapping for action
2009-12-04 18:22 2179<script type="text ... -
Cannot retrieve mapping for action 之 问题解决
2009-12-04 18:21 11333struts的form标 ... -
利用Struts的Validator验证框架实现客户端和服务器端双验证
2009-12-04 18:18 1538... -
struts的parameter功能
2009-12-04 17:32 1069没有struts之前,使用servlet,最常用的是d ...
相关推荐
在实际的Web应用程序开发中,通常一个URL对应一个Action,而`DispatchAction`则允许一个Action处理多个不同的请求,每个请求映射到Action中的不同方法,提高了代码的可维护性和组织性。 `DispatchAction`的核心机制...
DispatchAction是Struts提供的一个可扩展的Action类,它允许开发者将一个单一的Action类拆分成多个子方法,每个子方法处理特定的业务逻辑,从而提高了代码的组织性和可维护性。 DispatchAction的工作原理是通过...
总之,Struts DispatchAction是Java Web开发中一种有效的请求分发机制,它允许在一个Action类中组织和管理多个业务处理方法,提高了代码的可读性和可维护性。然而,随着技术的发展,如Struts2的出现,开发者可以选择...
其核心作用是允许将多个原本需要独立 Action 处理的任务合并到一个 Action 中进行处理,从而简化了 Action 的管理和维护工作。 **1.1 为什么要使用 DispatchAction** 在传统的 Struts 应用中,每一个业务逻辑操作...
在早期的Struts版本中,`DispatchAction`类是一个核心组件,它允许我们通过单一的Action类处理多个请求,通过在请求URL中指定不同的方法名来调用不同的业务逻辑。 标题提到的"Struts中等同于DispatchAction类方法...
`EventDispatchAction`是`DispatchAction`的一个子类,主要功能是简化处理多个提交按钮的情况。与`LookupDispatchAction`相比,它的使用更为便捷,无需与属性文件关联,也不需要手动在`getKeyMethodMap`方法中进行...
- `DispatchAction`降低了Action与视图之间的耦合度,因为它不需要为每一个请求创建一个新的Action类。 - 但是,这种方式也增加了Action自身的复杂度,因为一个Action类需要处理多种业务逻辑。 **示例代码**: ```...
如果希望在保持每个请求路径对应一个`<action>`元素的同时,又能够在一个Action类中处理多个请求路径,可以选择继承`MappingDispatchAction`。 **配置示例**: ```xml <action path="/mapping/login" type=...
DispatchAction是Struts提供的一个扩展Action类,它允许在一个Action类中实现多个业务处理方法,从而解决了创建大量Action类的问题。通常,一个Action类只有一个execute()方法,但通过DispatchAction,我们可以根据...
通常,一个Action类对应一个或多个业务逻辑方法,每个方法处理特定的用户请求。然而,当一个Action需要处理多种操作时,LookUpDispatchAction就显得特别有用。它通过基于请求参数的值来决定执行哪个业务方法,而不是...
- **使用DispatchAction**:如果一个Action需要执行多种不同的操作,可以考虑使用DispatchAction来简化代码结构。 - **增强灵活性**:通过使用`DynaActionForm`支持更灵活的表单数据处理。 综上所述,Struts框架的...
DispatcherAction 允许我们将一个 Action 分解为多个更小的 Action 方法,每个方法处理特定的业务逻辑。这样做的好处是代码结构更清晰,可维护性更强。通过在 Action 配置中指定对应的 execute 方法,...
5. DispatchAction:Struts1提供的一种特殊Action,它将一个请求分发到多个子方法,提高代码可维护性。 二、主要组件详解 1. Controller:在Struts1中,Controller由StrutsServlet和ActionServlet实现,它们负责...
DispatchAction是Struts提供的一种扩展机制,它允许我们在一个Action类中定义多个处理不同请求的方法,提高了代码的组织性和复用性。通过DispatchAction,我们可以减少Action Bean的数量,提升系统的可维护性。使用...
默认情况下,Struts1的动作类只有一个`execute()`方法,但使用`LookupDispatchAction`时,可以定义多个处理特定请求的方法,每个方法对应一个特定的请求参数。 二、配置与使用 1. 配置struts-config.xml 首先,需要...
DispatchAction是Struts提供的一种特殊类型的Action,用于解决一个Action中处理多个业务操作的问题。传统的Action通常只有一个execute方法,而DispatchAction则允许我们根据传入的参数值调用对应的方法。例如,在...
`DispatchAction` 在 Struts 1.2 版本中引入,它可以将一个 Action 映射到多个处理方法上。这使得一个 URL 可以对应不同的处理逻辑,提高了代码的复用性和灵活性。 例如,在配置文件中指定一个参数(如 `status`)...
1. **Action**:Action是业务逻辑处理的中心,负责接收请求,处理数据,并返回一个表示结果的ActionForward对象。开发者通常会自定义Action类,实现特定的业务逻辑。 2. **Form Bean**:Form Bean用于在视图和控制...
DispatchAction是Struts中一个非常实用的Action,它允许在一个表单中有多个提交按钮,每个按钮触发不同的处理逻辑。通过DispatchAction,开发者可以为不同的提交操作指定不同的处理方法,提高了代码的组织性和可复用...