- 浏览: 157124 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
semmy:
赞一个
displaytag的Excel导出实践 -
李君寻:
...
displaytag的Excel导出实践 -
xiaoz170:
不太明白为嘛包这一层 class ,反而使代码更复杂。难道是为 ...
试读《基于MVC的JavaScript Web富应用开发》— 不一样的JavaScript -
lingceng:
<mirror> <id>U ...
maven usage guide
Here is not basic use of struts2 json plugin but how to hack the code to set includeProperty dynamically, in othter words, set with action field not in xml file.
Train of thought:
I have a demand of changing includeParameter values when different ip request, I wonder whether I could set like this:
But failed.As we know, we can set filename like this when download file
do the hack:
I try to find out the different between json plugin and download plugin and find the way out to copy the ability.
Extend the json result class, add conditionalParse function, and filter in execute function.
last set the result class
Train of thought:
I have a demand of changing includeParameter values when different ip request, I wonder whether I could set like this:
<result type="json"> <param name="includeParameter">${allowedFields}</param> </result>
But failed.As we know, we can set filename like this when download file
<action name="download" class="action.DownloadAction"> <result name="success" type="stream"> <param name="contentType">application/octet-stream</param> <param name="contentDisposition">attachment;filename="${filename}"</param> <param name="bufferSize">1024</param> </result> </action>
do the hack:
I try to find out the different between json plugin and download plugin and find the way out to copy the ability.
Extend the json result class, add conditionalParse function, and filter in execute function.
public class JSONDynamicResult extends JSONResult { protected String conditionalParse(String param, ActionInvocation invocation) { return TextParseUtil.translateVariables(param, invocation.getStack(), new TextParseUtil.ParsedValueEvaluator() { public Object evaluate(Object parsedValue) { return parsedValue; } }); } public void execute(ActionInvocation invocation) throws Exception { ActionContext actionContext = invocation.getInvocationContext(); HttpServletRequest request = (HttpServletRequest)actionContext.get("com.opensymphony.xwork2.dispatcher.HttpServletRequest"); HttpServletResponse response = (HttpServletResponse)actionContext.get("com.opensymphony.xwork2.dispatcher.HttpServletResponse"); // fake code here, you shoud use a field to get "${allowedFields}" and test empty to compatible to origin use setIncludeProperty(conditionalParse("${allowedFields}",invocation)); try { Object rootObject = readRootObject(invocation); writeToResponse(response, createJSONString(request, rootObject), enableGzip(request)); } catch(IOException exception) { LOG.error(exception.getMessage(), exception, new String[0]); throw exception; } } }
last set the result class
<result-types> <result-type name="json" class="your.parckage.JSONDynamicResult "/> </result-types>
发表评论
-
Calender to Date snip
2013-05-30 10:25 898The format is not stored in the ... -
Gson切面日志实践
2013-02-26 17:47 2345背景 应用切面做日志记录,记录操作实体详情时可以使用JSO ... -
读《深入分析Java Web技术内幕》
2013-01-16 21:37 3297这里这本书的预读章节,看完预读部分,解答了一些疑惑 ... -
Java泛型
2012-11-08 23:57 1580Java的泛型是5.0的特性,自己的业务代码中或许较少使用 ... -
lucene全文索引
2012-11-08 01:45 1459总听说lucene,总听到“全文检索”,一直不大明白什么意 ... -
displaytag的汇总功能
2012-11-07 10:39 1043displaytag 有列汇总功能,以前不知道step1:需要 ... -
native2ascii使用
2012-10-29 13:56 1189native2ascii -[options] [inputf ... -
有效使用Java异常
2012-10-26 15:58 886Java的异常机制是一大优点,可以快速定位错误。但在实际开 ... -
从springside看到的
2012-10-26 00:27 1129springside是一个JAVAEE的开发框架,作者运用 ... -
JSTL小结
2012-10-12 12:00 1075网上有很多内容讲解, ... -
memcache simple practice in Java
2012-09-24 17:58 1615Memcache is C/S structure, serv ... -
displaytag中使用struts的国际化资源
2012-07-30 19:09 1367使用displaytag打印表格的时候,表头有时需要使 ... -
newInstance() and new
2012-07-11 14:00 1011相同点 newInstance() and new can ... -
Java Decompile
2012-07-05 15:58 960较早的eclipse的Java反编译是jad.exe ... -
Use JUnit
2012-07-05 13:20 889Junit A programmer-oriented te ... -
Use JUnit (2)
2012-07-05 13:04 858Junit3 diff Junit4 包命名从 ... -
《Java语言精粹》读书笔记(3)
2012-04-27 15:13 879集合 数据结构中的关于大型结构在java.util中提 ... -
《Java语言精粹》读书笔记(2)
2012-04-27 14:37 983Package Like most objec ... -
《Java语言精粹》读书笔记(1)
2012-04-14 16:30 891这是一本只讲Java优点的书。 Jim Wal ... -
JavaServer Pages Standard Tag Library
2012-03-29 14:45 917The JavaServer Pages Standa ...
相关推荐
struts2 json plugin jar包
struts2-json-plugin,Struts JSON插件
赠送jar包:struts2-json-plugin-2.3.24.jar; 赠送原API文档:struts2-json-plugin-2.3.24-javadoc.jar; 赠送源代码:struts2-json-plugin-2.3.24-sources.jar; 赠送Maven依赖信息文件:struts2-json-plugin-...
struts2整合json的插件struts2-json-plugin源码,不是jar包
jquery和struts2结合使用的jar包
struts2-spring-plugin-2.3.15.2.jar ; struts2-json-plugin-2.3.16.3.jarstruts2-spring-plugin-2.3.15.2.jar ; struts2-json-plugin-2.3.16.3.jar
struts2-json-plugin-2.2.3.1能用的包
struts2自带的json转换 倒入jar文件 struts.xml中 <package ......extends="json-default" <result type="json"/>
struts插件,放入classpath中即用!
struts2-json-plugin-2.2.3-sources.jar 源码
struts2-json-plugin-2.3.15.1 -Lee修复bug版.jarstruts2-json-plugin-2.3.15.1 -Lee修复bug版.jarstruts2-json-plugin-2.3.15.1 -Lee修复bug版.jarstruts2-json-plugin-2.3.15.1 -Lee修复bug版.jar
ajax结合Struts2要用到的jar包
struts2 2.3.16.3 版本配置json所需要的jar文件。有时候版本不一致也会配置失败。
struts2所需的包和Struts2 json所需包,直接导进去就能用,很适合新手开发以及测试Struts2返回json格式的数据。
struts2-json-plugin-2.3.24.jar
struts2-json-plugin-2.1.8.1.jar
包含struts2-core-2.5.10.1.jar,struts2-jfreechart-plugin-2.5.10.1.jar,struts2-json-plugin-2.5.10.1.jar,struts2-junit-plugin-2.5.10.1.jar,struts2-bean-validation-plugin-2.5.10.1.jar,struts2-cdi-...
struts2-json-plugin-2.1.8.jar