@action 注解
=================================================
下载 注解配置
private String fileName;
private String contentType = "application/octet-stream";
@Action(value = "/download", results = { @Result(name = "download", type="stream",
params={
"contentType","${contentType}",
"inputName","targetFile",
"contentDisposition","attachment;filename=${fileName}"
})
})
xml配置
<package name="fileService" namespace="/service/file" extends='struts-default'>
<action name="download" class="fileAction" method="view">
<result type="stream">
<param name="contentType">${contentType}</param>
<param name="inputName">targetFile</param>
<param name="contentDisposition">filename="${fileName}"</param>
</result>
</action>
<action name="delete" class="fileAction" method="delete">
<result>/result.jsp</result>
</action>
</package>
=================================================
struts-json 配置 参考
http://www.doc88.com/p-994525480794.html
@Controller
@Namespace("help")
@Component
@ParentPackage("json-default") //注意这边要加 json 默认不是json的
public class HotFaqAction extends BaseAction {
private List<FAQinfo> list;
@Reference(version = "1.0.0")
private FAQService fAQService;
/**
* 控件提交 注意这边type要给json 所有的属性都会序列化json 如果不想所有 就要过滤 过滤暂时没研究到
*/
@Action(value = "/helpMsgAddAjax", results = { @Result(name = NONE, type = "json" ) })
public String helpMsgAddAjax() {
list = fAQService.getHot(5, 0);
super.output("true");
return null;
}