Model view controller Struts中的多个操作

Model view controller Struts中的多个操作,model-view-controller,jakarta-ee,struts,Model View Controller,Jakarta Ee,Struts,我目前是JavaEE新手,刚刚完成JavaEE课程。我们被要求使用MVC Struts 1创建一个添加、编辑和删除程序 所以我的问题是,如何用多个动作来完成它?您是否有任何教程解释如何使用Struts创建成功的web应用程序? register.jsp <form name="myform"> // other inputs going here <input type="button" name="add" value="add" id="add" o

我目前是JavaEE新手,刚刚完成JavaEE课程。我们被要求使用MVC Struts 1创建一个添加、编辑和删除程序

所以我的问题是,如何用多个动作来完成它?您是否有任何教程解释如何使用Struts创建成功的web应用程序?

register.jsp

    <form name="myform">
    // other inputs going here
    <input type="button" name="add" value="add" id="add" onclick="submitAction(this)">
    <input type="button" name="update" value="update" id="update" onclick="submitAction(this)">
    <input type="button" name="delete" value="delete" id="delete" onclick="submitAction(this)">
    </form>

为什么要使用一个自2008年以来就没有更新过的框架,而这个框架已经被Stripes、SpringMVC、Play等更现代的框架淘汰了很长一段时间?Struts1死了。它不应该再用于新项目。如果您真的想使用STruts1,那么请查看其子类的and。阅读@JB Nizet well我还没有java方面的背景。我们不知道为什么奖学金项目仍然教我们struts而不是Spring或struts2。对于初学者,先生,你有什么建议?我还没有java编程的经验,我会建议你。它简单、高效,基于JEE进行了很好的设计和文档记录,并且只关注表示层(与Spring不同)。@JB Nizet好的,谢谢,先生..我会试试..谢谢你的回答..^^我建议看看JSF。这是最简单的MVC框架,它已经是JavaEE的一部分。无需下载、安装或配置任何内容。
function submitAction(actType)
{
document.myform.action = actType.id;
document.myform.submit();

}

<action name="MyUpdateAction" type="test.MyUpdateAction" path="/update" input="/register.jsp">
  <forward name="success" path="/updated.jsp" />
  <forward name="failure" path="/failure.jsp" />
</action>
<action name="MyAddAction" tepe="test.MyAddAction" path="/add" input="/register.jsp">
  <forward name="success" path="/added.jsp" />
  <forward name="failure" path="/failure.jsp" />
</action>
<action name="MyDeleteAction" type="test.MyDeleteAction" path="/delete" input="/register.jsp">
  <forward name="success" path="/deleted.jsp" />
  <forward name="failure" path="/failure.jsp" />
</action>
 public class MyUpdateAction extends org.apache.struts.action.Action {
    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception 
    {       //do update Stuff...
        if () {
            return mapping.findForward("success");
        } else {
                return mapping.findForward("failure");}
    }

    public class MyAddAction extends org.apache.struts.action.Action {
    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception 
        {           //do add Stuff...       
        if () {
            return mapping.findForward("success");
        } else {
                return mapping.findForward("failure");}
        }

    public class MyDeleteAction extends org.apache.struts.action.Action {
    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception 
        {       //do delete Stuff...    
        if () {
            return mapping.findForward("success");
        } else {
                return mapping.findForward("failure");}
        }