package com.athl.action;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.athl.bean.Person;
import com.athl.dao.PersonDao;
import com.athl.utils.CreateHtml;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import freemarker.template.TemplateException;
public class PersonAction extends ActionSupport implements ModelDriven<Person> {
private static final long serialVersionUID = -814210299977683837L;
private String url,msg;
private Person p;
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public Person getModel() {
if(p==null){
p= new Person();
}
return p;
}
public String getAll() throws Exception {
CreateHtml createHtml = new CreateHtml();
Map<String, List<Person>> map = new HashMap<String, List<Person>>();
map.put("personlist", new PersonDao().query());
System.out.println(map);
String htmlName = "personList";
String ftl = "list.ftl";
try {
createHtml.init(ftl, htmlName, map);
} catch (IOException e) {
e.printStackTrace();
} catch (TemplateException e) {
e.printStackTrace();
}
url = "/"+htmlName;
return "list";
}
public String addPage() throws Exception {
CreateHtml createHtml = new CreateHtml();
//Map<String, List<Person>> map = new HashMap<String, List<Person>>();
//map.put("personlist", new PersonDao().query());
String htmlName = "add";
String ftl = "add.ftl";
try {
createHtml.init(ftl, htmlName, null);
} catch (IOException e) {
e.printStackTrace();
} catch (TemplateException e) {
e.printStackTrace();
}
url = "/"+htmlName;
return "addPage";
}
public String add() throws Exception {
new PersonDao().add(p);
return getAll();
}
public String queryById() throws Exception {
CreateHtml createHtml = new CreateHtml();
Map<String, Person> map = new HashMap<String,Person>();
map.put("person", new PersonDao().queryById(p.getId()));
String htmlName = "update";
String ftl = "update.ftl";
try {
createHtml.init(ftl, htmlName, map);
} catch (IOException e) {
e.printStackTrace();
} catch (TemplateException e) {
e.printStackTrace();
}
url = "/"+htmlName;
return "update";
}
public String update() throws Exception {
new PersonDao().update(p);
return getAll();
}
public String delete() throws Exception {
new PersonDao().del(p.getId());
return getAll();
}
public String queryLike() throws Exception {
CreateHtml createHtml = new CreateHtml();
Map<String, List<Person>> map = new HashMap<String, List<Person>>();
map.put("personlist", new PersonDao().queryLike(msg));
String htmlName = "personListByLike";
String ftl = "list.ftl";
try {
createHtml.init(ftl, htmlName, map);
} catch (IOException e) {
e.printStackTrace();
} catch (TemplateException e) {
e.printStackTrace();
}
url = "/"+htmlName;
return "list";
}
}
FreeMarker与struts2整合生成静态页面
需积分: 9 99 浏览量
2017-01-07
20:16:44
上传
评论 2
收藏 4.7MB ZIP 举报
朱赤墨黑
- 粉丝: 25
- 资源: 60
最新资源
- 常用工具集参考用于图像等数据处理
- 音乐展示网页、基于Stenography的图像数字水印添加与提取,以及基于颜色矩和Tamura算法的图像相似度评估算法py源码
- 基于EmguCV(OpenCV .net封装),图像数字水印加解密算法的实现,其中包含最低有效位算法,离散傅里叶变换算法+文档书
- 基于matlab+DWT的图像水印项目,数字水印+源代码+文档说明+图片+报告pdf
- (优秀毕业设计)基于python实现的数字图像可视化水印系统的设计与实现,多种数字算法实现+源代码+文档说明+理论演示pdf
- 基于DWT-DCT-SVD和deflate压缩的数字水印方法python源码+Gui界面+演示视频(高分毕业设计)
- 基于matlab实现DWT、DCT、SVD算法数字图像水印可视化系统+GUI界面+文档说明+详细注释(高分毕业设计)
- NCIAE-Data-Structure大一大二笔记
- 学习wireshark笔记
- digital-image-数据可视化笔记
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈