/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.caiyi.guestbook.action;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
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.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import org.apache.taglibs.standard.lang.jstl.parser.SimpleCharStream;
import com.caiyi.guestbook.model.AdminDTO;
import com.caiyi.guestbook.model.GuestBookDAO;
import com.caiyi.guestbook.model.GuestBookDTO;
import com.caiyi.guestbook.util.Pagable;
public class GuestbookAction extends DispatchAction {
private Connection con;
private String cc;
public ActionForward guestList(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// 分页
String strPage = request.getParameter("page");
int showPage = 1;
if (strPage != null) {
showPage = Integer.parseInt(strPage);
}
// 搜索(拼凑SQL语句)
String sql = "select * from users where 1=1";
String sqlCount = "select count(*) from users where 1=1";
try {
System.out.println(1111111111);
con = this.getDataSource(request).getConnection();
GuestBookDAO dao = new GuestBookDAO(con);
List list = dao.findAll(sql, showPage, 4);
// 通过dao调用findRecordNum查詢出数据库里面的总记录数ͨ��dao����findRecordNum��ԃ����ݿ�������ܼ�¼��
int totalRecords = dao.findRecordNum(sqlCount);
con.close();
// 把所有分页的信息全部放到pagable里面去ȫ���ŵ�pagable����ȥ
Pagable pages = new Pagable(list, showPage, 4, totalRecords,
"guestbook.do?guest=guestList");
// 把pages对象里面的值存放到pages里
request.setAttribute("users", pages);
List slist = dao.finalladmin();
request.setAttribute("admin", slist);
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if (con != null & !con.isClosed()) {
con.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
return mapping.findForward("list");
}
public ActionForward guestsList(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// 分页
String strPage = request.getParameter("page");
int showPage = 1;
if (strPage != null) {
showPage = Integer.parseInt(strPage);
}
// 搜索(拼凑SQL语句)
String sql = "select * from users where 1=1";
String sqlCount = "select count(*) from users where 1=1";
try {
System.out.println(1111111111);
con = this.getDataSource(request).getConnection();
GuestBookDAO dao = new GuestBookDAO(con);
List list = dao.findAll(sql, showPage, 4);
// 通过dao调用findRecordNum查詢出数据库里面的总记录数ͨ��dao����findRecordNum��ԃ����ݿ�������ܼ�¼��
int totalRecords = dao.findRecordNum(sqlCount);
con.close();
// 把所有分页的信息全部放到pagable里面去ȫ���ŵ�pagable����ȥ
Pagable pages = new Pagable(list, showPage, 4, totalRecords,
"guestbook.do?guest=guestsList");
// 把pages对象里面的值存放到pages里
request.setAttribute("users", pages);
List slist = dao.finalladmin();
request.setAttribute("admin", slist);
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if (con != null & !con.isClosed()) {
con.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
return mapping.findForward("adminlist");
}
public ActionForward admin(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String username = request.getParameter("username");
String password = request.getParameter("password");
if (username == null && password == null) {
username = "";
password = "";
}
System.out.println("用户名"+ username);
System.out.println("密 码"+ password);
try {
con = this.getDataSource(request).getConnection();
GuestBookDAO dao = new GuestBookDAO(con);
AdminDTO dto = dao.findbyusername(username);
if (username == "") {
request.setAttribute("info","用户名,密码不能为空");
return mapping.findForward("login");
} else if (password.equals(dto.getPassword())) {
request.getSession().setAttribute("userInfo", dto);
return mapping.findForward("admin");
} else {
request.setAttribute("err","用户,密码错误");
return mapping.findForward("login");
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if (con != null & !con.isClosed()) {
con.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
return null;
}
public ActionForward guestPreEdit(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
System.out.println("guestPreEdit");
int id = Integer.parseInt(request.getParameter("id"));
try {
Connection con = this.getDataSource(request).getConnection();
GuestBookDAO dao = new GuestBookDAO(con);
GuestBookDTO dto = dao.finbyid(id);
request.setAttribute("dto", dto);
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if (con != null & !con.isClosed()) {
con.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
return mapping.findForward("edit");
}
public ActionForward guestPreEdit1(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
System.out.println("guestPreEdit1");
int id = Integer.parseInt(request.getParameter("id"));
try {
Connection con = this.getDataSource(request).getConnection();
GuestBookDAO dao = new GuestBookDAO(con);
GuestBookDTO dto = dao.finbyid(id);
request.setAttribute("dto", dto);
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if (con != null & !con.isClosed()) {
con.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
return mapping.findForward("re");
}
public ActionForward guestEdit1(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
System.out.println("guestEdit1");
String test = request.getParameter("recontent");
System.out.println("%%%%%%%%" + test);
int id = Integer.parseInt(request.getParameter("id"));
System.out.println("@@@@@@@" + id);
GuestBookDTO dto = new GuestBookDTO();
dto.setText(test);
dto.setId(id);
try {
Connection con = this.getDataSource(request).getConnection();
GuestBookDAO dao = new GuestBookDAO(con);
dao.update1(dto);
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if (con != null & !con.isClosed()) {
con.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
return mapping.findForward("admin");
}
public ActionForward guestEdit(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
System.out.println("guestEdit");
String name = request.getParameter("name");
String context = request.getParameter("content");
String text = request.getParameter("recontent");
int id = Integer.parseInt(request.getParameter("id"));
System.out.println("###########" + name);
System.out.println("###########" + context);
System.out.println("###########" + text);
Syste
没有合适的资源?快使用搜索试试~ 我知道了~
struts版的简单留言板
共94个文件
gif:32个
jar:16个
tld:8个
5星 · 超过95%的资源 需积分: 0 51 下载量 84 浏览量
2008-12-04
18:57:05
上传
评论 1
收藏 2.68MB RAR 举报
温馨提示
struts版的简单留言板struts版的简单留言板struts版的简单留言板
资源推荐
资源详情
资源评论
收起资源包目录
T-cay.rar (94个子文件)
T-cay留言板
GuestBook
.project 1KB
.settings
org.eclipse.core.resources.prefs 147B
.mymetadata 300B
WebRoot
login.jsp 3KB
WEB-INF
struts-tiles.tld 8KB
fmt.tld 19KB
.struts-config.mex 3KB
web.xml 1KB
struts-config.xml 1KB
struts-bean.tld 9KB
struts-nested.tld 70KB
struts-html.tld 72KB
struts-logic.tld 14KB
validator-rules.xml 13KB
lib
commons-logging.jar 37KB
commons-digester.jar 147KB
commons-fileupload.jar 19KB
commons-beanutils.jar 184KB
jstl.jar 20KB
commons-dbcp-1.2.1.jar 105KB
msbase.jar 278KB
antlr.jar 344KB
struts.jar 474KB
commons-validator.jar 74KB
mssqlserver.jar 63KB
commons-collections-3.1.jar 546KB
msutil.jar 58KB
commons-pool-1.2.jar 41KB
jakarta-oro.jar 62KB
standard.jar 384KB
classes
com
caiyi
guestbook
action
GuestbookAction.class 10KB
model
GuestBookDAO.class 5KB
GuestBookDTO.class 2KB
AdminDTO.class 757B
ApplicationResources.properties 92B
util
Pagable.class 3KB
EncodingFilter.class 1KB
c.tld 16KB
fn.tld 7KB
index.jsp 986B
META-INF
MANIFEST.MF 39B
add.jsp 10KB
list.jsp 9KB
img
TT_r.gif 654B
1.gif 5KB
Forum_nav.gif 650B
icon_reply_topic.gif 159B
bg.gif 140B
TT_left.gif 1KB
toplogo2.jpg 16KB
top1.gif 2KB
icon_editor_oicq.gif 576B
TT_back.gif 204B
end2.gif 85B
toplogo1.jpg 11KB
icon_delete_reply.gif 157B
icon_edit_topic.gif 560B
fav_add.gif 1KB
shareforum.gif 1KB
top2.gif 141B
BJ-2.GIF 147B
1_r.gif 630B
logo.gif 3KB
topicnew.gif 1KB
0.gif 4KB
toplogobg.jpg 8KB
1_back.gif 187B
icon_profile.gif 579B
beijing.gif 128B
Thumbs.db 52KB
topicnonew.gif 663B
end3.gif 504B
icon_email.gif 124B
top3.gif 1KB
topichotnonew.gif 1KB
end1.gif 331B
icon_homepage.gif 579B
locktop.gif 1KB
topichot2.gif 1KB
re.jsp 3KB
slist.jsp 9KB
edit.jsp 4KB
style.css 1KB
.myeclipse
src
com
caiyi
guestbook
action
GuestbookAction.java 10KB
EncodingFilter.java 508B
model
GuestBookDAO.java 5KB
GuestBookDTO.java 1KB
AdminDTO.java 400B
ApplicationResources.properties 92B
util
Pagable.java 2KB
.mystrutsdata 262B
.classpath 2KB
guestbook_Log.LDF 1024KB
guestbook_Data.MDF 1024KB
共 94 条
- 1
资源评论
- 国宝小殷2014-12-22借鉴一下,部分参考用作期末大作业
wzju64676266
- 粉丝: 130
- 资源: 22
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功