freemarker与jquery整合
--------------------编程问答-------------------- 现在我决定用freemarker生成html数据流,并通过json传入前台已有的静态页面上,但是不知道freemarker在java代码中如何获取到生成的静态页面的html字符串,代码如下,我只获取到了writer对象--------------------编程问答-------------------- 建议:可以不同的权限返回不同的json,然后再前台用jquery使用返回的json显示相应地方的内容,在action中见一个Map<String,String>存放键值对应情况,再把map放进list里返回,struts会自动转换,struts里action需要配置继承的是json-default,百度一下会有格式的,仅供参考 --------------------编程问答-------------------- 请参考我的基于spring,security的开源项目
String proPath = this.getClass().getResource("/").getPath();
System.out.println(proPath+"com/wy/template");
/* 在整个应用的生命周期中,这个工作你应该只做一次。 */
/* 创建和调整配置。 */
Configuration cfg = new Configuration();
cfg.setDirectoryForTemplateLoading(
new File(proPath+"com/wy/template"));
cfg.setObjectWrapper(new DefaultObjectWrapper());
/* 在整个应用的生命周期中,这个工作你可以执行多次 */
/* 获取或创建模板*/
Template temp = cfg.getTemplate("pointShow.ftl");
/* 创建数据模型 */
Map root = new HashMap();
root.put("points", points);
/* 将模板和数据模型合并 */
Writer out = new OutputStreamWriter(System.out);
temp.process(root, out);
out.flush();
//this.out="<p>ceshi</p>";
http://blog.csdn.net/shadowsick
补充:Java , Web 开发