struts2简单的回传ajax数据方法

<pre class="java" name="code" snippet_file_name="blog_20140607_1_4605417" code_snippet_id="381193">//Action里面:
//输入流private InputStream inputStream; public InputStream getInputStream() { return inputStream; } // bbs注册处理 public String bbsRegister() { String name = users.getUserName(); if (name.equals("admin") || name.equals("")) { inputStream = new StringBufferInputStream("<font color=red>no,you cat't use this name!</font>"); } else { inputStream = new StringBufferInputStream("<font color=red>yes,you can register!</font>"); } return "bbsRegister"; } // struts.xml的配置: <action name="bbs*" class="bbsAction" method="bbs{1}"> <result type="stream" name="bbsRegister"> <param name="contentType">text/html</param> <param name="inputName">inputStream</param> </result> </action>
 
 


 

你可能感兴趣的:(struts2简单的回传ajax数据方法)