...
In Struts 2, we can do the same thing with a Stream result.
Note | ||
---|---|---|
| ||
Using a Struts 2 plugin (e.g., JSON plugin, jQuery plugin, etc.) is, in general, preferred to writing the response directly from within an action. See sections following this for further details. |
Code Block | ||||
---|---|---|---|---|
| ||||
package actions; import java.io.InputStream; import java.io.StringBufferInputStream; import com.opensymphony.xwork2.ActionSupport; public class TextResult extends ActionSupport { private InputStream inputStream; public InputStream getInputStream() { return inputStream; } public String execute() throws Exception { inputStream = new StringBufferInputStream("Hello World! This is a text string response from a Struts 2 Action."); return SUCCESS; } } |
...