0

我在struts 1中有应用程序。

在用户填写表格后,我有邮寄表格(收件人、发件人、主题、正文等)。调用动作(按下发送按钮),该动作将从表单中获取数据并发送邮件

在这里,当邮件失败时,我必须将用户发送回相同的邮件表单,其中包含他输入的相同数据(即相同的 ActionForm )

有人可以帮助我如何在 Struts 1 中实现这一点

4

1 回答 1

0

这应该可以帮助您入门。

在 struts 配置文件中,如果失败,页面将被重定向到“input”属性值,在本示例中为“email.jsp”页面。

Struts 配置文件:

<struts-config>
        <form-beans>
        <form-bean name="emailForm" type="com.EmailForm">
       </form-bean>
    </form-beans>
    <action path="/sendEmail"
        type="com.SendEmailAction"
        scope="request" name="mailForm" 
        input="email.jsp"
        parameter="getCgrs">
        <forward name="success" path="email.jsp"></forward>
    </action>
</struts-config>

你的jsp页面:

<html:form action="/sendEmail" >
   <html:text property = "toEmail" />
   <input type="submit" value="Send Email"/>
</html:form>

在您的表单类中,您应该有一个与您的 jsp 页面中的属性相匹配的属性“toEmail”。

public class EmailForm extends ActionForm{
    private String toEmail;
    public void setToEmail(String toEmail){
         this.toEmail = toEmail;
    }
    public String getToEmail(){
         return toEmail;
    }
}
于 2013-05-03T20:33:49.840 回答