package com.tang.action;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.tang.entity.Students;
import com.tang.service.StudentService;
import flexjson.JSONSerializer;
import flexjson.transformer.DateTransformer;
@SuppressWarnings("serial")
public class ListAction extends ActionSupport{
//注入biz
//@Resource
private StudentService studentService;
public void setStudentService(StudentService studentService) {
this.studentService = studentService;
}
public StudentService getStudentService() {
return studentService;
}
public String getJsonString() {
return jsonString;
}
public void setJsonString(String jsonString) {
this.jsonString = jsonString;
}
private String jsonString ="";
private long stuid;
public long getStuid() {
return stuid;
}
public void setStuid(long stuid) {
this.stuid = stuid;
}
public String getStuname() {
return stuname;
}
public void setStuname(String stuname) {
this.stuname = stuname;
}
public String getStusex() {
return stusex;
}
public void setStusex(String stusex) {
this.stusex = stusex;
}
public Date getStubrith() {
return stubrith;
}
public void setStubrith(Date stubrith) {
this.stubrith = stubrith;
}
public String getStuemail() {
return stuemail;
}
public void setStuemail(String stuemail) {
this.stuemail = stuemail;
}
private String stuname;
private String stusex;
private Date stubrith;
private String stuemail;
//添加信息
public String add() throws Exception
{
try {
Students stu = new Students();
HttpServletResponse response = ServletActionContext.getResponse();
HttpServletRequest request =ServletActionContext.getRequest();
String name=request.getParameter("stuname");
String sex=request.getParameter("stusex");
String brith=request.getParameter("stubrith");
String email=request.getParameter("stuemail");
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
stu.setStuname(name);
stu.setStusex(sex);
stu.setStubrith(sf.parse(brith));
stu.setStuemail(email);
studentService.saveStudent(stu);
response.getWriter().write("{success:true}");
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
//删除信息
@SuppressWarnings("unchecked")
public String del() throws Exception
{
HttpServletResponse response = ServletActionContext.getResponse();
HttpServletRequest request =ServletActionContext.getRequest();
String id = request.getParameter("id");
List list = studentService.getOneStudent(Long.parseLong(id));
if(list.size()!=0)
{
Students s = (Students) list.get(0);
studentService.delStudent(s);
}
response.getWriter().write("{success:true}");
return null;
}
//编辑信息
public String edit() throws Exception
{
Students stu = new Students();
HttpServletResponse response = ServletActionContext.getResponse();
HttpServletRequest request =ServletActionContext.getRequest();
String id = request.getParameter("stuid");
String name=request.getParameter("stuname");
String sex=request.getParameter("stusex");
String brith=request.getParameter("stubrith");
String email=request.getParameter("stuemail");
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
stu.setStuid(Long.parseLong(id));
stu.setStuname(name);
stu.setStusex(sex);
stu.setStubrith(sf.parse(brith));
stu.setStuemail(email);
studentService.updateStudent(stu);
response.getWriter().write("{success:true}");
return null;
}
//得到所有的学生信息
@SuppressWarnings("unchecked")
public String getlist() throws Exception
{
try {
HttpServletResponse response = ServletActionContext.getResponse();
@SuppressWarnings("unused")
HttpServletRequest request = ServletActionContext.getRequest();
//得到所有用户
List list = studentService.getAllStudent();
//josn
JSONSerializer json = new JSONSerializer();
json.transform(new DateTransformer("yyyy-MM-dd"), new String[] {
"stubrith"});
String jsonStr =json.serialize(list);
String jsons = "{success:true,rs:"+jsonStr+"}";
this.setJsonString(jsons);
response.setCharacterEncoding("utf-8");
response.getWriter().write("{success:true,rs:"+jsonStr+"}");
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
//编辑前初始化(根据id得到学生信息)
@SuppressWarnings("unchecked")
public String toEdit() throws Exception
{
HttpServletResponse response = ServletActionContext.getResponse();
HttpServletRequest request =ServletActionContext.getRequest();
String stuid= request.getParameter("stuid");
System.out.println(stuid);
List list = studentService.getOneStudent(Long.parseLong(stuid));
if(list.size()!=0){
JSONSerializer jsonSer = new JSONSerializer();
jsonSer.transform(new DateTransformer("yyyy-MM-dd"), new String[] {
"stubrith"});
String jsonStr = jsonSer.serialize(list);
String jsonStrin = "{success:true,rs:"+jsonStr+"}";
setJsonString(jsonStrin);
response.setCharacterEncoding("utf-8");
response.getWriter().write("{success:true,rs:"+jsonStr+"}");
}
return null;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
ExtJs+SSH的增删改查
共2000个文件
svn-base:4982个
svn-work:4982个
gif:1961个
4星 · 超过85%的资源 需积分: 10 29 下载量 193 浏览量
2012-03-21
11:02:38
上传
评论 4
收藏 39.41MB RAR 举报
温馨提示
一个用ExtJs+SSH+Oracle写的增删改查,里面有数据库的Sql语句,非常完整,全面!Ext的资源文件也有,不用再添加!Ext用的是3.0
资源推荐
资源详情
资源评论
收起资源包目录
ExtJs+SSH的增删改查 (2000个子文件)
ListAction.class 6KB
StudentsDAO.class 5KB
StudentServiceImpl.class 2KB
StudentDaoImpl.class 2KB
Students.class 1KB
StudentService.class 372B
StudentDao.class 360B
.classpath 7KB
xtheme-default2.css 138KB
xtheme-default16.css 134KB
ext-all.css 132KB
ext-all-css04.css 132KB
ext-all-css03.css 132KB
ext-all-css05.css 132KB
ext-all-notheme.css 95KB
xtheme-access.css 40KB
xtheme-blue.css 37KB
yourtheme.css 37KB
xtheme-gray.css 37KB
xtheme-tp.css 37KB
xtheme-vista.css 26KB
calendar.css 26KB
ux-all.css 20KB
ytheme-vista.css 13KB
grid.css 11KB
form.css 10KB
button.css 8KB
tabs.css 7KB
panel.css 7KB
grid.css 6KB
grid.css 6KB
grid.css 6KB
panel-reset.css 6KB
GroupTab.css 6KB
toolbar.css 5KB
core.css 5KB
layout.css 5KB
date-picker.css 5KB
tree.css 4KB
menu.css 4KB
tree.css 4KB
form.css 4KB
window.css 3KB
tree.css 3KB
tree.css 3KB
button.css 3KB
toolbar.css 3KB
tabs.css 3KB
date-picker.css 3KB
editor.css 3KB
tabs.css 3KB
resizable.css 3KB
date-picker.css 3KB
statusbar.css 3KB
date-picker.css 3KB
form.css 3KB
tabs.css 3KB
toolbar.css 3KB
toolbar.css 3KB
qtips.css 3KB
form.css 2KB
button.css 2KB
button.css 2KB
StatusBar.css 2KB
panel.css 2KB
panel.css 2KB
slider.css 2KB
panel.css 2KB
Ext.ux.UploadDialog.css 2KB
window.css 2KB
menu.css 2KB
ext-patch.css 2KB
window.css 2KB
RowActions.css 2KB
window.css 2KB
core.css 2KB
resizable.css 2KB
resizable.css 2KB
core.css 2KB
resizable.css 2KB
menu.css 2KB
list-view.css 1KB
core.css 1KB
RowEditor.css 1KB
box.css 1KB
box.css 1KB
box.css 1KB
box.css 1KB
menu.css 1KB
Spinner.css 1KB
ColumnNodeUI.css 1KB
layout.css 1KB
layout.css 1KB
layout.css 1KB
qtips.css 1KB
qtips.css 1KB
qtips.css 1KB
GridFilters.css 1KB
dialog.css 1KB
treegrid.css 1KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
- w333652013-01-18没有数据库没部署成
- akuikly2013-07-09解压出错,不可用
- abcd9532abcd2013-09-18解压出错,不可
summer景
- 粉丝: 0
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功