I am trying to rewrite this sample code from the FAQ using zero configuration annoations:

http://struts.apache.org/2.1.2/docs/how-can-we-return-a-text-string-as-the-response.html

and I came up with this:


import java.io.InputStream;
import java.io.StringBufferInputStream;

import org.apache.struts2.config.Result;
import org.apache.struts2.dispatcher.StreamResult;

import com.opensymphony.xwork2.ActionSupport;

@Result(value = "", type = StreamResult.class, params =
{
   "contentType",
   "text/html",
   "inputName",
   "inputStream" })
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;
   }
}

But when I run it I get this exception:

ERROR dispatcher.StreamResult - Can not find a java.io.InputStream with the name [] in the invocation stack. Check the <param name="inputName"> tag specified for this action.

The first thing I wondered about is the "value" parameter in @Result. It is required, but I wasn't sure what to pass.

Any help to get this sample code to work using annotations would be appreciated.

Thanks,  John


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to