在Struts2中调用多个方法

时间:2016-08-26 08:28:03

标签: struts2

我有一个LoginAction课程,其中我有三个方法execute()read()write()。在执行方法中,我使用:

调用readwrit方法
LoginAction l1 = new LoginAction();l1.read();l1.write(null);
execute file-----upload file from directory.
read and write------------read uploaded file and convert it into excel.

在我的struts.xml中,我编写了这些调用这些方法的步骤。

 action name="login" class="net.myapp.struts.LoginAction"
 method="execute" 

但在运行时只有一种方法(execute方法)正在运行。我该如何调用所有方法?

我的方法是:

public String execute() throws Exception
boolean write(List<String> l1) throws Exception
public String Read() throws Exception
form tag. s:form action="login1" method="post" enctype="multipart/form-data"
        namespace="/".

1 个答案:

答案 0 :(得分:0)

为此我们可以在Struts 2中使用链接。一个动作导致另一个动作,依此类推。 请求&GT;措施1&GT;措施2&GT;措施3&GT;响应。 http://viralpatel.net/blogs/struts-2-action-chaining-example/