`
除了你无可取代
  • 浏览: 144487 次
  • 性别: Icon_minigender_1
  • 来自: 悲鸣洞穴
社区版块
存档分类
最新评论

@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;
    }

 

分享到:
评论
1 楼 di1984HIT 2014-04-24  
不错啊。挺好啊。

相关推荐

Global site tag (gtag.js) - Google Analytics