java - How to override the XML handler in the Struts 2 REST plugin -
i working on java web app uses struts 2 rest plugin. convention, url ends ".xml" sent through xstreamhandler. fine--it's want in cases.
but in small number of cases want stream xml browser. know how set @result(type="stream") annotation , make return inputstream. i've done images in other parts of app. problem returning xml stream rest plugin sees caller requesting xml tries deserialize action class instead of streaming out inputstream.
how can tell rest plugin, in these few special cases, not send xml result through xstreamhandler?
thanks!
oh, cool, figured out answer. secret return instance of class implements com.opensymphony.xwork2.result
.
assuming 'getfilename()' returns name of xml file want stream:
@skipvalidation public com.opensymphony.xwork2.result streamfile() throws filenotfoundexception { return new streamresult(new fileinputstream(new file(getfilename()))); }
Comments
Post a Comment