I was ok to define it in struts.xml config.
<action name="getImage" class="my.action.GetImageAction">
<result name="success" type="stream">
<param name="contentType">image/jpeg</param>
<param name="inputName">imageStream</param>
<param name="bufferSize">1024</param>
</result>
</action>
And I am now trying to define it by annotation on the class with namesapce, result path, and I have no idea how to do it. Please help 🙂
I have tried
@Namespace("/my/namespace")
@ResultPath("/")
@Result(name = "success", type = "imageResult")
public class GetImageAction extends ActionSupport {
.....
@Override
@Action("/getImage")
public String execute() throws Exception {
.....
And I got an error
HTTP Status 404 - No result defined for action
As the error says the results have to be defined at the Action.
The definition would look like this
In the example you see the type too and how to define the contentType.
And the stream will be returned by the “getFileInputStream”-method:
the “getContentDisposition”-Method has to be available in the Action-class