1

In the execute method of the Struts Action class, we have the following four parameters, HttpServletRequest, HttpServletResponse, ActionForm, ActionMapping

Does this mean that any other protocol other than Http is not supported by STRUTS??? I wonder!

Also, in Struts v2.x we do not have these parameters embedded in to the execute method. Does it mean that Struts support all protocols from the Version 2.0?

4

2 回答 2

2

IN short it is not,Struts was developed to provide a better warpper around the way standard HTTP based web-application was being developed.

Idea behind the framework was to make the development more easily and more flexible by taking away the complexities of the underlying HTTP protocol on which it was working.

In core of the system even Strut use HTTP Request and Repose to perform its functions and other work for you.

Update: Framework follow Servlet specification so it will for support ServletRequest request, ServletResponse response

You asked about Struts2 signature so here is the answer for that, Struts2 provides a clean way to make your Action POJO based so as to make the testing easily that does not mean it not support Servlet specifications,

Struts2 has cleaned the execute method signature so as to remove the underlying servlet dependencies on your Acton class but under the hood it uses set of interceptors to take away the HTTP complexities out of your action class and make it easy to go ahead to write unit test cases.

Though Xwork which is core of S2 allow you to write standalone application but that is not very well publicize fact

于 2012-07-26T06:35:49.307 回答
1

Struts is a wrapper to support HTTP based web application in better way. In back it uses mechanism based on Servlet.

It also has Servlet API.jar as dependency.

Every Struts Action class extends Action and By default overrides execute method with

public ActionForward execute(ActionMapping mapping,
                             ActionForm form,
                             HttpServletRequest request,
                             HttpServletResponse response)

Check http://struts.apache.org/1.x/apidocs/org/apache/struts/action/Action.html#execute%28org.apache.struts.action.ActionMapping,%20org.apache.struts.action.ActionForm,%20javax.servlet.ServletRequest,%20javax.servlet.ServletResponse%29

There is a method for Non-Http requests also.

于 2012-07-26T06:37:42.720 回答